Ninja fails to build JUCE project, can't find includes

I am following the guide here to get a project up and running:

I want to write code in Sublime Text and use its build system to run ninja. This is my go-to workflow and it works great on other projects (unrelated to JUCE).

I successfully installed JUCE as outlined, and created the build tree for my project with this command:

-cmake -Bbuild -G Ninja -DCMAKE_PREFIX_PATH=“A:/Audio/JUCE”

I will note that after the build kept giving me errors about mutexes, I found that I needed to run VS’s vcvars64.bat to get the build tree to use the right compiler instead of my default mingw (which I thought would work?). Anyways, so it generates properly now. When I run it with ninja within the same windows cmd context that I just created the build tree with, it builds fine and I run the exe to see the hello world window. But, if I close cmd and reopen it and try to run ninja again (or run it in ConEmu, or run it in Sublime Text’s build system), I get this error:

A:\Audio\JUCE\include\JUCE-7.0.8\modules\juce_core\system/juce_StandardHeader.h(50): fatal error C1083: Cannot open include file: ‘algorithm’: No such file or directory
ninja: build stopped: subcommand failed.

I imagine “algorithm” is arbitrary here and that the point is that it can’t find the general c++ includes. I don’t understand why this happens after I reopen cmd or use any other system to run the ninja build command. Everything is exposed to the same system path. I’ve tried rerunning the vcvars64.bat again beforehand, I’ve tried restarting my computer, I’ve ensured that cmake, gcc, and everything else is up to date, I’ve installed every relevant c++ package from the VS installer, I’ve perpetually deleted the build folder and tried again, I run cmd in administrator… not sure what to do now. Any help?

Sorry to hear your having issues get things up and running. It’s not a setup I’m completely familiar with but in an attempt to reduce the surface area of what might be going wrong it might be worth removing JUCE from the equation and simply create a basic C++ project that includes a standard header using CMake. You mentioned other projects were working fine but you didn’t say if those are C++ projects?

OK so I was wrong, running vcvars64.bat again before building fixes it. So if I write this in my Sublime build system, it works:

“cmd”: “"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvars64.bat" && ninja -C build”

This is really annoying to have to run it every build though, especially since the .bat takes a few seconds. The general problem seems to be that what I usually use for c++ projects is MinGW, which I guess is the default compiler on my system. If I want to use the VS compiler, I have to run vcvars. I would use MinGW for the JUCE project so that I can skip vcvars (initializing the VS compiler), but I just keep getting errors that say “error: ‘mutex’ in namespace ‘std’ does not name a type” when the build tree was made with MinGW. I’ll try to figure it out.

So I guess the issue is my c++ compiler, not JUCE. Thanks.

1 Like