Manually linking to JUCE sources without PROJUCER

Hello guys!

I’m getting started with JUCE mainly to use its OSC and MIDI functionality. I work mainly in QT and I’m trying to manually link to the JUCE modules using QT’s MSVC2017 compiler (worth mentioning I used visual studio 2017 to load a PROJUCER-generated project which worked with no issues at all so there is no issue with the files I downloaded).

I’ve tried to recreate a header similar to the master header PROJUCER makes. These are the lines I have in the header of the class I’m trying to use with JUCE:

#include <juce_core/juce_core.h>

I’ve referenced JUCE/modules/ as my include / depend path and my understanding is that this includes all the top module headers and sources of the library, but when I try to compile I get these charming errors:

LNK2019: unresolved external symbol "public: __cdecl juce::this_will_fail_to_link_if_some_of_your_compile_units_are_built_in_debug_mode::this_will_fail_to_link_if_some_of_your_compile_units_are_built_in_debug_mode(void)" (??0this_will_fail_to_link_if_some_of_your_compile_units_are_built_in_debug_mode@juce@@QEAA@XZ) referenced in function void __cdecl juce::dynamic initializer for 'compileUnitMismatchSentinel''(void)" (??__EcompileUnitMismatchSentinel@juce@@YAXXZ)

LNK2001: unresolved external symbol "public: __cdecl juce::this_will_fail_to_link_if_some_of_your_compile_units_are_built_in_debug_mode::this_will_fail_to_link_if_some_of_your_compile_units_are_built_in_debug_mode(void)" (??0this_will_fail_to_link_if_some_of_your_compile_units_are_built_in_debug_mode@juce@@QEAA@XZ)

What an absolute dream. I get a similar error in Release mode saying basically the same thing (some units are built in release mode).

Any tips on how to get around this?


1 Like

Hi guys,

Any thoughts on this? I tried using a PROJUCER-made setup as well (with AppConfig.h and JuceHeader.h) with no success.


Building JUCE in a completely custom way is quite complicated, and isn’t really supported. In this particular instance, it sounds like JUCE is being built in one configuration, but the JUCE headers are included in a project that uses a different build configuration.

It’s vital that when including JUCE, the JUCE headers always use exactly the same set of preprocessor definitions, in every place they are included (so, both in the JUCE .cpp/.mm files and in your dependent sources). This includes things like module configuration flags, and the DEBUG/NDEBUG flags that are causing this particular error.

JUCE 6, currently in technical preview on the juce6 branch, includes official CMake support which should make it easier to integrate into other projects. I’d recommend trying that out to see whether it’s workable for your use-case, rather than trying to create a new build from scratch.

1 Like

Thanks very much for the detailed response. This means that Juce 6 makes it possible to build DLLs using CMAKE? Is this currently accessible or will it only be available after the technical review?
If this release is currenty not available, are there any examples I could start with to get things going in the meantime?


You find the JUCE 6 preview branch in the very same git repository where you find the usual JUCE 5 master / develop branch, just switch to juce6

At the moment, JUCE’s CMake support is centred around support for plugin, gui-app, and console-app targets. Support for other types of targets (staticlibs, DLLs) should be possible, but there are no examples for these kinds of targets.

Are you able to share any more details about your project? For example, why are you interested in a JUCE DLL in particular? If you can provide some more details, I can try to advise how best to proceed with JUCE 6 and CMake.

Makes sense, as long as building DLLs using CMAKE is possible, I can take a crack at that.

For sure. I’m mainly looking to use the MIDI and OSC classes in JUCE along with a QT GUI project. QT does have some libraries for audio and network but looking through JUCE documentation it seems it is a lot more straightforward. I don’t necessarily need DLLs, I can use the modules directly.

I’ve had no luck with this guys, I’d appreciate any thoughts on where to start (links to other threads or something similar).

Did you ever figure this out? Been thinking about integrating Qt into a project but haven’t tried anything yet

I ended up using RtMIDI and OSCPack directly to make the classes I needed but I have an idea of how to do this; you probably just need to make a QT static library project and add the JUCE sources to that and compile it to make a JUCE static library.

Although if you want to integrate QT into JUCE that would be the reverse of what I wanted to do. Your situation might need a lot less work since Visual Studio already has a QT plugin you can use if you’re using Windows. So you can start with JUCE and then use that plugin to link to QT modules: