Heap corruption error when linking to shared code

Hi everyone,

I’m integrating GTest in a project to test VSTs, using FRUT to make .jucer and CMakeLists.txt files cohabit.

Here’s my issue (on Windows 10, juce v6.1.5)
I’m linking to the shared code target using

target_link_libraries(unitTestsMyPlugin PRIVATE gtest_main myplugin_Shared_Code)

One of the class I’m instanciating in the test has the following private members :

private:
#ifdef DEBUG
	juce::AudioProcessLoadMeasurer profiler;
	juce::Time initTime;
#endif

I get a heap corruption error in juce::AudioProcessLoadMeasurer when those are present in the class, but if I remove them there are no issue. The plugin compiles and runs without any errors when linked to shared code.

I read that this could be due to linking to a library compiled with a difference windows runtime, but i’m compiling everything using the Multithreaded static debug runtime …

Do you know what could be causing this ?

My guess is that you are linking against a shared code library which was built in Release mode (or in some mode without DEBUG defined).

It is absolutely imperative that you use exactly the same set of preprocessor flags that were used to build the shared code target when building test executable.

1 Like

Thank you, you are correct, the reason seemed to be that I did not define the DEBUG flag in my test. Now I don’t have the heap corruption error anymore !

I should probably switch to using JUCE_DEBUG to remember this is set by the Projucer.