Visual Studio 2019 16.8.3 has a bug? Open CMake Unknown error

Building and customizing Audacity from the source code.
Forum rules
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
Post Reply
wpostma
Posts: 13
Joined: Fri Mar 19, 2021 11:23 pm
Operating System: Windows 10

Visual Studio 2019 16.8.3 has a bug? Open CMake Unknown error

Post by wpostma » Sun Mar 21, 2021 7:01 pm

Following the instructions to build audacity, the instructions for getting the custom version of wx built worked perfectly. At the point of opening the CMakeLIst file from Open > CMake... the first time things went well until this line, which I don't follow completely and could perhaps be a tad more verbose. I do not see anything called "Verify Toolset". Not sure what that means, or what I should have seen but I didn't see it.

The instructions DID say these were done with 16.8.5, which I think must be a minimum. I suspect my tools were slightly out of date. (16.8.3).
The latest release March 21, is 16.9.2. I'll be trying that later today...

Code: Select all

 b) Open the CMake GUI

     Open VS 2019 > "continue without code" > File > Open > CMake
     Open CMakeLists.txt in root of audacity source folder you cloned

     Wait for the CMake Overview Pages tab to appear (be patient)
	   Click "Open the CMake Settings Editor" in this new tab
	   Scroll up to the top of the window and settings
	   In the Configurations window, click the green "+", then select x86-Release
	   Set Configuration type: Release

	   Verify Toolset: msvc_86
	   Keep Build Root: ${projectDir}\out\build\${name} (default, you can 
     change it) (this corresponds to CMAKE_BINARY_DIR)

     Click on "Show advanced settings" (scroll down).
	   Change CMake generator: VS 16 2019 (was Ninja)
	   Click "Save and Generate CMake cache to load variables" once, then
	   Click "Save and Generate CMake cache to load variables" a second time
	     or select Project > Generate CMake Cache
I continued merily onward and did what I could and then tried to click Project > Generate CMake Cache.

Next time I reopen visual studio, I reopen the cmake project like this:

File > Open > CMake...

And I get this error:

An error occurred in [Unknown]
open Cmake Settings in visual studio 2019:

This is in Visual Studio 16.8.3 which I realize is .2 below the readme notes. My updater is now update to 16.9.2 and I'll update this thread if that clears it up.

Another error that happens is from the CMake page where you click open open settings editor and this happens:

message dialog:
System.ArgumentException: Value does not fall within the expected range.

I think that is also a CMake-tooling bug in VS2019.

Could the CMake setup thing perhaps itself be scripted to occur from the command line, perhaps as a "visual_studio_bootstrap.py" (python 3.x) or "visual_studio_bootstrap.ps1" (powershell). Since the tooling in Visual Studio is a bit wonkoid, always. Last time I did C++ dev in Visual Studio I don't think CMake tooling existed so I should be happy this stuff exists.

Let me just give some HUGE kudos to whoever did write the existing build instructions as they are hands down above the usual open source build on windows instructions. Kudos, kind people.

I will update this thread to confirm that VS 2019 windows build 16.9.2 works once I sort that out. Another question is shouldn't the instructions for building tell the user to build the x64 and x86 Library binaries for the Audacity-fork-of-WX, since most people are going to be building Audacity 64 bit? That would mean that they should check that ..\wx...\lib\vc_x64_dll folder exists as well.

jademan
Forum Crew
Posts: 1188
Joined: Fri Jul 17, 2009 10:11 pm
Operating System: Please select

Re: Visual Studio 2019 16.8.3 has a bug? Open CMake Unknown error

Post by jademan » Sun Mar 21, 2021 7:34 pm

Thanks for the report.

One of the fun things about Visual Studio 2019 and CMake is that it is constantly multi-threading, and updating the screen in the background while you are trying to control what is going on. Unfortunately, this can result in too many cooks spoiling the brew. My advice is to be patient and wait. Then, be patient and wait again. I am not sure if I have used the "Project > Cmake" thingy recently, that is a legacy held-over instruction, but I think it should work. I do find that I have to click on the "Save and Generate.." at least two times. It can be very frustrating having to click on something a second time and waiting to put in the next command when the screen or tab isn't even available and there is no clue that it will magically appear in about 45 seconds time..... ;)

When you select x86-Release, it should set Configuration type to Release and Toolset to msvc_86, just verify it (also legacy instructions).
wpostma wrote:
Sun Mar 21, 2021 7:01 pm
Could the CMake setup thing perhaps itself be scripted to occur from the command line, perhaps as a "visual_studio_bootstrap.py" (python 3.x) or "visual_studio_bootstrap.ps1" (powershell). Since the tooling in Visual Studio is a bit wonkoid, always. Last time I did C++ dev in Visual Studio I don't think CMake tooling existed so I should be happy this stuff exists.
This is an all volunteer army. Is this something you would like to put together ? ;)
wpostma wrote:
Sun Mar 21, 2021 7:01 pm
I will update this thread to confirm that VS 2019 windows build 16.9.2 works once I sort that out. Another question is shouldn't the instructions for building tell the user to build the x64 and x86 Library binaries for the Audacity-fork-of-WX, since most people are going to be building Audacity 64 bit? That would mean that they should check that ..\wx...\lib\vc_x64_dll folder exists as well.
ditto. ;)

wpostma
Posts: 13
Joined: Fri Mar 19, 2021 11:23 pm
Operating System: Windows 10

Re: Visual Studio 2019 16.8.3 has a bug? Open CMake Unknown error

Post by wpostma » Wed Mar 24, 2021 12:50 am

SOLVED. Got it working.

After updating Visual Studio 2019, the next time through I got this error:

https://i.imgur.com/wKl5mf0.png

Severity Code Description Project File Line Suppression State
Error (active) Generator is targeting x86, but x64 environment is inherited. C:\audiodev\audacity\CMakeSettings.json 5
Error (active) Generator is targeting x86, but x64 environment is inherited. C:\audiodev\audacity\CMakeSettings.json 17
Warning C4005 'INFINITY': macro redefinition (compiling source file C:\audiodev\audacity\lib-src\lv2\lilv\src\plugin.c) C:\audiodev\audacity\out\build\x64-Debug (default)\audacity C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\corecrt_math.h 88

I have no idea what this part of the build instructions means:

Verify Toolset: msvc_86
Keep Build Root: ${projectDir}\out\build\${name} (default, you can
change it) (this corresponds to CMAKE_BINARY_DIR)


However I think my problem was solved by making sure these two things are matchy matchy same, same, and that the regeneration of CMake internals is re-done until CMake is happy.

Image

After that, IT WORKS, IT WORKS. The part I had to repeat was:

Click on "Show advanced settings" (scroll down).
Change CMake generator: VS 16 2019 (was Ninja)
Click "Save and Generate CMake cache to load variables" once, then
Click "Save and Generate CMake cache to load variables" a second time
or select Project > Generate CMake Cache

Then build again.


Next question I wondered at was having the Visual Studio IDE be able to debug is simply a matter of selecting which Startup Item visual studio will use, as in this animated gif I have just prepared...

https://i.imgur.com/Kr7ts6e.gif

If a video showing these steps being done would be helpful, I could perhaps make one and post it on Youtube and that might help some folks get this building.

If the Windows instructions had this section maybe it would be great:

Debugging Audacity

0. Make sure it built first and check the output directory contains the exe.
1. Select the Startup Item
(show image)
2. Debug >Start Debugging (F5)

Probably that is considered "too basic" for people with Visual Studio experience, but it wouldn't hurt to have that in the wiki.

It seems that all binary dependencies are placed in the folder to let audacity launch, but perhaps some extra bits should be manually copied over, such as LAME?

wpostma
Posts: 13
Joined: Fri Mar 19, 2021 11:23 pm
Operating System: Windows 10

Re: Visual Studio 2019 16.8.3 has a bug? Open CMake Unknown error

Post by wpostma » Wed Mar 24, 2021 1:28 am

Question:

Looking at the source, when I see an ifdef block like this, what's the idiomatic way within this project structure to set these defines?


#ifdef EXPERIMENTAL_DA
#include "../images/DarkAudacityLogoWithName.xpm"
#else
#include "../images/AudacityLogoWithName.xpm"
#endif

Where would one set that? Is there a "config.h", or is it Audacity.h where you would do that?

I am about 20 years out of date on my C++ skills. Time to brush up on std::unique_ptr<X> and such. The 90s called and they want my elite 1998 era C++ coding skills back. :-)

Ermegerhd what is CallAfter( [=] () mutable {.... ;-) Help I'm being eaten by a wild lambda.

jademan
Forum Crew
Posts: 1188
Joined: Fri Jul 17, 2009 10:11 pm
Operating System: Please select

Re: Visual Studio 2019 16.8.3 has a bug? Open CMake Unknown error

Post by jademan » Wed Mar 24, 2021 11:18 am

wpostma wrote:
Wed Mar 24, 2021 12:50 am
SOLVED. Got it working.
Congratulations! :D
wpostma wrote:
Wed Mar 24, 2021 1:28 am
Question:

Looking at the source, when I see an ifdef block like this, what's the idiomatic way within this project structure to set these defines?

#ifdef EXPERIMENTAL_DA
...
I suspect you will find it illustrative to check out this pull request: https://github.com/audacity/audacity/pull/761

I hope this helps. :D

wpostma
Posts: 13
Joined: Fri Mar 19, 2021 11:23 pm
Operating System: Windows 10

Re: Visual Studio 2019 16.8.3 has a bug? Open CMake Unknown error

Post by wpostma » Sat Mar 27, 2021 5:01 am

I see. So these defines are typically passed into cmake as command line arguments now?

jademan
Forum Crew
Posts: 1188
Joined: Fri Jul 17, 2009 10:11 pm
Operating System: Please select

Re: Visual Studio 2019 16.8.3 has a bug? Open CMake Unknown error

Post by jademan » Sat Mar 27, 2021 10:58 am

That is a question for the audacity developer's mailing list: https://www.audacityteam.org/community/developers/

I hope this helps. :D

Post Reply