Unable to compile with Visual Studio 2017

Whenever I try to compile Audacity in Visual Studio 2017, the projects libnyquist, libsndfile, and lv2 throw this error:

#error: Macro definition of snprintf conflicts with Standard Library function declaration

I’m following this guide, except I’m using wxWidgets 3.0.3 without the patch, because 3.0.2, with or without the patch, throws the same error. When I open the Audacity solution file, VS asks whether to upgrade the project; I let it do so, because if I don’t, then compilation fails because the v120_xp build tools aren’t installed (and I don’t think I can install them).

That guide says:

Audacity releases for Windows are currently built with > Microsoft Visual Studio 2013 C++

The Express edition is no longer available, so you will need to use the Community edition.

You may also find this page useful. It’s some proposed updates to the instructions and aims to clarify some points in the current instructions: Missing features - Audacity Support

That’s not supported either. Build with VS2013 Community Edition and wxWidgets 3.0.2.


Gale

Using VS Community 2013 and wxWidgets 3.0.2 worked.

To be honest, I thought that the Visual Studio installer linked at the top of this page would just download and install whatever the latest version of Visual Studio happened to be (2017 currently). Good thing I was wrong. (And that was the day after the link was fixed.)

Many of the VS2013->VS2015/VS2017 compile problems come from the various stdint.h and inttypes.h files included to allow builds with versions of Visual Studio older than VS2012 where the included SDK did not provide those header files (or was it VS2013?). The SDK that comes with VS2015 started relying on the Microsoft versions of those files, so providing custom ones that override the system’s headers causes a lot of grief. There are also a few #if changes needed in a few places. You may want to look at the now ancient “henricj” pull requests for the official audacity or look at the “Update _MSC_VER #if blocks.” change here: Commits · henricj/audacity · GitHub (the link to the actual commit changes when I rebase on top of new changes from the main audacity archive).

I would not recommend using my fork unless you are comfortable reading through the changes that have made there. Cherry-picking the changes you need would be safer. I rarely do anything other than smoke test a VS2017/v141 x64 build that is statically linked against an LTCG build of the head of the wxWidgets tree. If you do want to build it, set WXWIN_VS2017 to point to wxWidgets (3.0.3, 3.1, and HEAD should all work, but recently I’ve only tested HEAD; 3.0.3 would be the most conservative choice), make sure the VS2017 installer set VS150COMNTOOLS (IIRC, run the installer again to make sure you have Update 2 if that is not the case), run the “build_wx2017.bat” in the “win” directory to get the wxWidgets stuff built, then “build_2017.bat” to build audacity itself. Take a look in “win\build\bin\v141\x64\Static Release” and hopefully there should be an audacity.exe. If you need the translations, you will need to copy them from the “Release” directory (“Static Release” only relinks what was done for “Release”, so the Language stuff isn’t re-generated).

This may also be of interest: [Audacity-devel] wxWidgets 3.0.3 & VS2017 | Audacity

Is the text on that page not clear as to what will be downloaded? From my testing it gets VS2013 Community Edition Update 4.

Stating the obvious, we cannot fix the link until we know it has become broken. The problem arises from Audacity only supporting obsolete versions of VS, but then it is work for us to upgrade too.


Gale

The text is clear enough. Before I actually tried to run the installer, though, I thought that any “vs_community.exe” from Microsoft, including the one linked to in the guide, would just download and install the newest version of Visual Studio. (There are plenty of outdated guides, and not just for Audacity, that provide links that are supposed to point to particular versions of software that now actually point to newer versions, because either the links point to web installers that only install the latest versions, the links are for the main product pages that only offer the newest versions, or the link targets turned into redirects to the main product pages. Looking at the history of that guide, I can see that before June 6, 2017, that link was the second of these.)