Linker Issue When Building Ugen

I’m getting this issue when I try to build a plugin I’m working on and I don’t know how to fix it. It looks like I need to update the .cpp.o file but my understanding of Cmake is pretty superficial and I am not sure how to do that.

/usr/local/Cellar/cmake/3.26.4/bin/cmake -S/Users/josiahsytsma/LFSRNoiseUgens -B/Users/josiahsytsma/LFSRNoiseUgens/build --check-build-system CMakeFiles/Makefile.cmake 0

/usr/local/Cellar/cmake/3.26.4/bin/cmake -E cmake_progress_start /Users/josiahsytsma/LFSRNoiseUgens/build/CMakeFiles /Users/josiahsytsma/LFSRNoiseUgens/build//CMakeFiles/progress.marks

/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/Makefile2 all

/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/LFSRNoise_scsynth.dir/build.make CMakeFiles/LFSRNoise_scsynth.dir/depend

cd /Users/josiahsytsma/LFSRNoiseUgens/build && /usr/local/Cellar/cmake/3.26.4/bin/cmake -E cmake_depends "Unix Makefiles" /Users/josiahsytsma/LFSRNoiseUgens /Users/josiahsytsma/LFSRNoiseUgens /Users/josiahsytsma/LFSRNoiseUgens/build /Users/josiahsytsma/LFSRNoiseUgens/build /Users/josiahsytsma/LFSRNoiseUgens/build/CMakeFiles/LFSRNoise_scsynth.dir/DependInfo.cmake --color=

Dependencies file "CMakeFiles/LFSRNoise_scsynth.dir/plugins/LFSRNoise/LFSRNoise.cpp.o.d" is newer than depends file "/Users/josiahsytsma/LFSRNoiseUgens/build/CMakeFiles/LFSRNoise_scsynth.dir/compiler_depend.internal".

**Consolidate compiler generated dependencies of target LFSRNoise_scsynth**

/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/LFSRNoise_scsynth.dir/build.make CMakeFiles/LFSRNoise_scsynth.dir/build

[ 25%] Building CXX object CMakeFiles/LFSRNoise_scsynth.dir/plugins/LFSRNoise/LFSRNoise.cpp.o

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -DLFSRNoise_scsynth_EXPORTS -DNOVA_SIMD -I/Users/josiahsytsma/supercollider/external_libraries/nova-simd -I/Users/josiahsytsma/supercollider/include/plugin_interface -I/Users/josiahsytsma/supercollider/include/common -I/Users/josiahsytsma/supercollider/common -std=gnu++17 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -mmacosx-version-min=12.6 -fPIC -fvisibility=hidden -MD -MT CMakeFiles/LFSRNoise_scsynth.dir/plugins/LFSRNoise/LFSRNoise.cpp.o -MF CMakeFiles/LFSRNoise_scsynth.dir/plugins/LFSRNoise/LFSRNoise.cpp.o.d -o CMakeFiles/LFSRNoise_scsynth.dir/plugins/LFSRNoise/LFSRNoise.cpp.o -c /Users/josiahsytsma/LFSRNoiseUgens/plugins/LFSRNoise/LFSRNoise.cpp

[ 50%] **Linking CXX shared module LFSRNoise_scsynth.scx**

/usr/local/Cellar/cmake/3.26.4/bin/cmake -E cmake_link_script CMakeFiles/LFSRNoise_scsynth.dir/link.txt --verbose=1

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -mmacosx-version-min=12.6 -bundle -Wl,-headerpad_max_install_names -o LFSRNoise_scsynth.scx CMakeFiles/LFSRNoise_scsynth.dir/plugins/LFSRNoise/LFSRNoise.cpp.o

Undefined symbols for architecture x86_64:

"_LFSRNoise_next_k", referenced from:

_LFSRNoise_Ctor in LFSRNoise.cpp.o

ld: symbol(s) not found for architecture x86_64

clang: **error:** **linker command failed with exit code 1 (use -v to see invocation)**

make[2]: *** [LFSRNoise_scsynth.scx] Error 1

make[1]: *** [CMakeFiles/LFSRNoise_scsynth.dir/all] Error 2

make: *** [all] Error 2

Please post a link to the repo. It is difficult to spot the actual problem without seeing the actual code and CMakeLists.txt.

There is typo in L 62 :slight_smile:

LSFRNoise_next_kLFSRNoise_next_k

The linker complained because it couldn’t find the definition for the declaration in L.17.


Side note: the extern "C" clause in L.14-18 is not necessary, since these functions won’t be exported or called from C code. (extern "C" just disables C++ name mangling.)

Thanks! I didn’t really understand what that clause was about.

It took me a good half hour to even spot the typo after you pointed it out :joy: