CLion Errors

So after about 13 straight hours of debugging arcane error messages to get a basic example to compile on Windows 10 with CLion, I’d like to share the hoops I had to jump through to to get everything up and running so nobody else will have to.

I first attempted to use the Projucer, but was met with the “missing memory and excpt.h” error messages that were supposedly fixed in 5.1. Changing the windows build target did nothing to remedy this, but I didn’t plan on using the Projucer to build so I wasn’t too concerned.

It should probably have been mentioned that one specifically needs mingw with the posix thread model, because the win thread model version of mingw doesn’t contain <mutex>.

After getting this fixed, the builds still failed due to object files exceeding the maximum size. adding the -mbig-obj flag allowed it to finally compile.

In addition to this, in CLion I only have the STANDALONE_PLUGIN and SHARED_CODE build targets. I don’t see any way to build a VST.

However, build times are still painfully slow. Is this part of using CMake instead of VS, or is there something I can do to speed up build times?

Builds using the MinGW toolchain can take a long time to link. If they’re building via makefiles (which I think is what CLion does) the builds may not be parallelised to use all of the available cores on the build machine. You could consider (in order of complexity):

  • Add -jn to your build flags where N is the number of hardware threads on your machine. This will parallelise make appropriately.
  • Installing Ninja and adding -GNinja to your configuration flags (or possibly -DCMAKE_MAKE_PROGRAM=ninja -GNinja. In both cases you’ll need to add Ninja to your Path environment variable). Ninja automatically parallelises to use as many hardware threads as you have available.
  • Use MSVC with NMake, or use ClangCL, both of which are supported by CLion now. You might be able to combine these speedier compilers with Ninja or parallelised make for really fast builds.

Personally I’ve been really happy with results from building CMake projects with ClangCL and Ninja, although I haven’t tried that under CLion. I’ll give that a go now and update this post when I know how well it works.


Just tried building the UnitTestRunner using CLion and ClangCL. Debug mode linking was very quick, as was the speed of the overall build - definitely faster than MinGW.

1 Like

How does one use MSVC with CLion for building on windows? I get 7254 warnings and 4 errors attempting a build. Each of the errors seem to be something about:
error: cannot use 'try' with exceptions disabled
Or the same, but with throw.
Adding -fcxx-exceptions to the compile flags doesn’t seem to fix this.

I’m not sure about the Projucer-generated CMakeLists (in this case it sounds like the /EHsc flag is missing). If you use the standalone CMake support in JUCE 6, the default settings should work without adjusting any flags.

Is there a tutorial somewhere for setting up a project with and using the standalone CMake w/ Juce 6?

1 Like

There are no tutorials yet, but on the juce6 branch there is a set of examples in examples/CMake which can act as starting points for new projects. There’s also documentation for JUCE’s CMake API in examples/CMake/ Finally, all of the examples/extras projects that ship with JUCE have been updated with CMake builds, which may be useful as further examples.

1 Like