Audacity Build – Win10+VS2015

Wherein I’m keeping track of what I am doing to try and successfully build Audacity on Windows 10, using Visual Studio Community 2015, (VSC++2015), with wxWidgets 3.1.0 on an x64 bit machine, although using Audacity build in x32 as is it’s native mode. Maybe later it will be possible to change it? to either both, or pure x64?

I will be updating this page constantly over the next 130 years probably ….

wxWidgets compiles successfully in both x32 and x64 bit mode, with VS2015
Audacity – not so easy…..

But first – apply the fixes to wxWidgets mentioned way further in  this text related to snprintf _snprintf .. you must do it.

Really, also, do the comment out bit for the patches. I suspect that it’s now way out of date for 3.1.0 – as it’s a 3.0.2 patch.

If you are reading this for clues – be aware that in the end, this exercise may be fruitless. In the extreme. Audacity has been cobbled together over some 10 years, and even now is still insisting on being developed with ancient software in most cases. Because it hasn’t been moved forward as compilers and os’ have moved forward, it is in many cases now hopelessly outdated. So delve into this if you have nothing better to do. If you are developing on one of the many versions of Linux – enjoy, this is ONLY VS2015 based.

Audacity is a really useful program, and does what it is designed to do remarkably well. I use it myself for producing Audiobooks and other podcast type things. I recommend it. I use it on an Apple Mac – yet another platform where development of it has stalled.

I will be doing the same on OSX as I’m doing with this. Running a page as I update it. The OSX 10.11.4 + 10.11 SDK builds (again) wxWidgets fine. Audacity – not so.

Start:

STEP 2

First up, had to uninstall .NET 4.6*.* and everything behind it. To get the SDK installed, which installs .NET 4 along with it.

On my windows 10, I went into services, and stopped almost everything, especially non windows programs.

Then I uninstalled all the .NET instances on the system, and all the VS10 instances on the system.

I stopped windows firewall, and norton, and norton live-monitor. Almost nothing running.

Then

Install DirectX Windows.

Install WindowsSDK V7, Which comes with .NET 4 handily.

I already have Visual Studio Community 2015 installed.

So once you get over the Windows stupidness, you are good to go.

.NET Framework 4 is installed
SDK V7 installed.

DirectX Windows is installed

Probably spend a year now updating these things..

==========

Use git to install Audacity into a directory that has no spaces. Pull it in with git, the easiest.

“E:\git clone https://github.org/audaqcity/audacity Audacity”

This will put it into a directory ready, called Audacity, right where your cursor is. So if you are on Drive E:\ in this case, you end up with E:\Audacity

ie; E:\Audacity – NOT… E:\My Souces Programs\Audacity

 

Download wxWidgets-3.1.0.zip and unpack into a directory next to it. In my case, E:\wxWidgets-3.1.0

The current latest version.

 

Now firstly, look in E:\wxWidgets-3.1.0\build\msw\wx_vc14.sln

Don’t worry. VC14 is VC15. Don’t ask, I don’t know…

Open VisualStudio2015, and select that file and open it.

 

Read the Audacity Document.

Building Audacity® for Microsoft Windows(R)

But be careful. Some of it is now incorrect.

The Audacity and early wxWidget docs ask you to open this file, [wx_dll.dsw]  but it no longer exists in 3.1.0.

Open E:\Audacity\win\audacity.sln

 

Instead, when the sln file opens, look for DLL Debug and DLL Release in drop down tab on top bar. Leave set to Win32 – Audacity doesn’t have much/any x64 code.

Build Selection in VS2015, the selections as detailed in section 2.3 – all selections just to be sure. You will see them in the selection tab.

This will build the Debug DLLs. (Although I note that there aren’t that many more in the list anyway.
Result: 14 Succeeded. 0 Failed.
Comment out two versions of snprintf … see notes …

Found as
#define snprintf _snprintf
In VS2015
Use Edit -> Find and Replace -> Find in Files -> Entire Solution (Including External Items ) – OR – Entire Solution will usually do it.
#define snprintf _snprintf

and if you want to play dangerously, Find and Replace with
//#define snprintf _snprintf

Put this into
\audacity\lib-src\libnquist\nyquist\nyqstk\globals.h
… #include <cstdio.h>

to avoid the “symbol cabnnot bve used in a using-declaration” and is not a member of global_namespace … errors

Ignore patches and comment out wxMSWDisableSettingHighDPIAware … in /Audacity/AudacityApp.cpp

 

Dealing with Error.

================== Begin MS Reference ==================

Microsoft Development

<cstdint>

Visual Studio 2015 

Includes the Standard C library header <stdint.h> and adds the associated names to the std namespace.

Syntax

#include <cstdint>

Remarks

Including this header ensures that the names declared using external linkage in the Standard C library header are declared in the std namespace.

See Also

C++ Standard Library Header Files
C++ Standard Library Overview

========================== end of this reference ============

 

Build Error Reference Lists. MS

 

========================== Compiler Warning References =====

Compiler Warning (level 4) C4100

Visual Studio 2015 

‘identifier’ : unreferenced formal parameter

The formal parameter is not referenced in the body of the function. The unreferenced parameter is ignored.

C4100 can also be issued when code calls a destructor on a otherwise unreferenced parameter of primitive type. This is a limitation of the Visual C++ compiler.

The following sample generates C4100:

// C4100.cpp
// compile with: /W4
void func(int i) {   // C4100, delete the unreferenced parameter to
                     //resolve the warning
   // i;   // or, add a reference like this
}

int main()
{
   func(1);
}
 Continued.

Compiler Error C2039

Compiler Error C2039

Visual Studio 2015 

‘identifier1’ : is not a member of ‘identifier2’

The code incorrectly calls or refers to a member of a structure, class, or union.

Example

The following sample generates C2039.

// C2039.cpp
struct S {
   int mem0;
} s, *pS = &s;

int main() {
   pS->mem1 = 0;   // C2039 mem1 is not a member
   pS->mem0 = 0;   // OK
}

Example

The following sample generates C2039.

// C2039_b.cpp
// compile with: /clr
using namespace System;
int main() {
   Console::WriteLine( "{0}", DateTime::get_Now());   // C2039
   Console::WriteLine( "{0}", DateTime::Now);   // OK
   Console::WriteLine( "{0}", DateTime::Now::get());   // OK
}

Example

The following sample generates C2039.

// C2039_c.cpp
// compile with: /clr /c
ref struct S {
   property int Count {
     int get();
     void set(int i){}
   };
};

int S::get_Count() { return 0; }   // C2039
int S::Count::get() { return 0; }   // OK

Example

C2039 can also occur if you attempt to access a default indexer incorrectly. The following sample defines a component authored in C#.

// C2039_d.cs
// compile with: /target:library
// a C# program
[System.Reflection.DefaultMember("Item")]
public class B {
   public int Item {
      get { return 13; }
      set {}
   }
};

Example

The following sample generates C2039.

// C2039_e.cpp
// compile with: /clr
using namespace System;
#using "c2039_d.dll"

int main() {
   B ^ b = gcnew B;
   int n = b->default;   // C2039
   // try the following line instead
   // int n = b->Item;
   Console::WriteLine(n);
}

Example

C2039 can also occur if you use generics. The following sample generates C2039.

// C2039_f.cpp
// compile with: /clr
interface class I {};

ref struct R : public I {
   virtual void f3() {}
};

generic <typename T>
where T : I
void f(T t) {
   t->f3();   // C2039
   safe_cast<R^>(t)->f3();   // OK
}

int main() {
   f(gcnew R());
}

Example

C2039 can occur when you try to release managed or unmanaged resources. For more information, see Destructors and finalizers.

The following sample generates C2039.

// C2039_g.cpp
// compile with: /clr
using namespace System;
using namespace System::Threading;

void CheckStatus( Object^ stateInfo ) {}

int main() {
   ManualResetEvent^ event = gcnew ManualResetEvent( false );   
   TimerCallback^ timerDelegate = gcnew TimerCallback( &CheckStatus );
   Timer^ stateTimer = gcnew Timer( timerDelegate, event, 1000, 250 );

   ((IDisposable ^)stateTimer)->Dispose();   // C2039

   stateTimer->~Timer();   // OK
}

Compiler Errors C2800 Through C2899

Compiler Error C2873

Visual Studio 2015 

‘symbol’ : symbol cannot be used in a using-declaration

using directive is missing a namespace keyword. This causes the compiler to misinterpret the code as a using declaration rather than a using directive.

 =============================================================================

 

snprintf stuff.

Compiler Warning (level 1) C4005

Visual Studio 2015 

‘identifier’ : macro redefinition

The macro identifier is defined twice. The compiler uses the second macro definition.

To fix by checking the following possible causes

  1. Defining a macro on the command line and in the code with a #define directive.

  2. Macros imported from include files.

To fix by using the following possible solutions

  1. Remove one of the definitions.

  2. Use an #undef directive before the second definition.

The following sample generates C4005:

// C4005.cpp
// compile with: /W1 /EHsc
#include <iostream>
using namespace std;

#define TEST "test1"
#define TEST "test2"   // C4005 delete or rename to resolve the warning

int main() {
   cout << TEST << endl;
}

Fatal Error C1189

Visual Studio 2015 

#error : user supplied error message

C1189 is generated by the #error directive. The developer who codes the directive specifies the text of the error message. For more information, see #error Directive (C/C++).

The following sample generates C1189. In the sample, the developer issues a custom error message because the _WIN32 identifier is not defined:

// C1189.cpp
#undef _WIN32
#if !defined(_WIN32)
#error _WIN32 must be defined   // C1189
#endif

You might also see this error if you build an ATL project by using the /robust MIDL compiler option. Use the /robust switch to build only Windows 2000 and later versions of Windows. To correct this error, use one of the following procedures:

  • Change this line in the dlldatax.c file:
#define _WIN32_WINNT 0x0400   // for WinNT 4.0 or Windows 95 with DCOM

to:

#define _WIN32_WINNT 0x0500   // for WinNT 4.0 or Windows 95 with DCOM
  • Use the Advanced property page in the MIDL property page folder to remove the /robust switch and then specify the /no_robustswitch. For more information, see MIDL Property Pages: Advanced.
Dealing with snprintf problems in both wxWidgets, and Audacity
1) <wxdir>\src\zlib\gzguts.h – line 102
change:

CODE: SELECT ALL

#ifdef _MSC_VER
#  define snprintf _snprintf
#endif

to:

CODE: SELECT ALL

#if (defined(_MSC_VER) && (_MSC_VER < 1900))
#define snprintf _snprintf
#endif

2) <wxdir>\src\tiff\libtiff\tif_config.h – line 367
change:

CODE: SELECT ALL

#define snprintf _snprintf

to:

CODE: SELECT ALL

#if (defined(_MSC_VER) && (_MSC_VER < 1900))
#define snprintf _snprintf
#endif

 

Open inVS2015, and set to Release build. then, Rebuild Solution – not Build.

0 Errors. 3 Warnings.

I can live with that.

 

Now, lets look at modifying Audacity. Same deal – Do the Release build. I’m sure there is a big difference.

Firstly, make sure that a copy of setup0.h from wsWidgets-3.0.1\include\wx\msw\setup0.h is placed in  wsWidgets-3.0.1\include\wx\local.h  – note the zero (0) is removed. Similar to the wxWidgets build instructions.

For some reason I can’t be bothered tracking down, VS2015 isn’t finding it in its native directory.

So also, in your 2015 Project Properties, add the INCLUDE E:\wsWidgets-3.1.0\include\wx\msw … and probably forget about moving the setup.h as instructed above. With that include path, everything starts to build… so far.

hmmm – this leads me to thinking ….

So having given up on the snprintf error for the moment, I’,m attempting to reduce the number of Warnings.

Starting at the top of the list, I’m eliminating first the

C4146 warnings. These are particularly tricky ones to get rid of, and fortunately

unary minus operator applied to unsigned type.result still unsigned

VisualStudio 2015 tells you which file the warnings are to be found in. But – not how to fix them.

Either use a type with more precision to represent the constant

int val = -2147483648L;
// or
int val = -2147483648LL;

(depending on which type has more precision than int on your platform).

Or resort to the good old - 1 trick

int val = -2147483647 - 1;

or, you could also use the INT_MIN macro from limits.h if the goal is to get the lowest possible integer value