Duplicate symbol errors (createDspObject/getModuleList/destroyDspObject) compiling DspNetwork as Dynamic Library on macOS
-
Environment: macOS, HISE develop branch (up to date with origin/develop), Xcode, compiling a DSP Network as Dynamic Library via batchCompileOSX.sh.
Error:
duplicate symbol '_createDspObject' in:
duplicate symbol '_getModuleList' in:
duplicate symbol '_destroyDspObject' in:
ld: 20 duplicate symbolsDiagnosis:
Usingnmon the compiled .o files, I confirmed these symbols are defined in THREE separate object files instead of one:- Main.o
- include_hi_tools_01.o
- include_hi_tools_03.o
The function bodies live in HiseLibraryHeader.h, guarded by:
#if HI_EXPORT_DSP_LIBRARY
...
#endifHI_EXPORT_DSP_LIBRARY is set to 1 in AppConfig.h (autogenerated from the .jucer's ), which is correct/intentional for exporting the DLL.
The problem: hi_tools_01.cpp and hi_tools_03.cpp both #include "../hi_dsp_library/hi_dsp_library.h" (confirmed via grep), which pulls in HiseLibraryHeader.h and re-generates the factory functions in those translation units as well — in addition to Main.cpp, which is the intended single exporter.
This seems like it shouldn't happen — hi_tools shouldn't normally depend on hi_dsp_library at all (dependency direction is usually reversed). Is this expected, or is this a bug in how the hi_tools amalgamation includes hi_dsp_library.h? Toggling IS_STATIC_DSP_LIBRARY in Projucer did not change the outcome.
Happy to share the exact grep/nm commands and full build log if helpful.