[CMake] Linking problems

Alexander Neundorf a.neundorf-work at gmx.net
Fri Apr 17 11:10:54 EDT 2009


On Friday 17 April 2009, John Dey wrote:
> Alex,
>
> Thanks for your input.  I changed the compile option from number "0"
> to alphabet "O".  Reran cmake and then ran "make VERBOSE=1" as you
> suggest (see output below).  I noticed that the compiler is c++ in
> cmake while the compiler used in the successful link used g++.  I
> changed the compiler in the cache to g++ but there was no difference.
> Why does the program link with the hand compile but not with cmake?
>
> John
>
> /usr/bin/c++   -D__LITTLE_ENDIAN__ -D__MACOS_CORE__ -D__GXX__ -I/Users/
> robo3/Music/MyProj/Play/PlayAeolus/src   -g -Wall -O3 -o CMakeFiles/
> playsmf.dir/Stk.cpp.o -c /Users/robo3/Music/MyProj/Play/PlayAeolus/src/
> Stk.cpp
> Linking CXX executable playsmf
> "/Applications/CMake 2.6-3.app/Contents/bin/cmake" -E
> cmake_link_script CMakeFiles/playsmf.dir/link.txt --verbose=1
> /usr/bin/c++    -Wl,-search_paths_first -headerpad_max_install_names -
> fPIC CMakeFiles/playsmf.dir/playsmf.cpp.o CMakeFiles/playsmf.dir/
> MidiFileIn.cpp.o CMakeFiles/playsmf.dir/RtMidi.cpp.o CMakeFiles/
> playsmf.dir/Stk.cpp.o  -o playsmf  -framework CoreAudio -framework
> CoreFoundation -framework CoreMidi /usr/lib/libpthread.dylib /usr/lib/
> libm.dylib
> Undefined symbols:
>    "RtMidiOut::sendMessage(std::vector<unsigned char,
> std::allocator<unsigned char> >*)", referenced from:
>        _main in playsmf.cpp.o
>        _main in playsmf.cpp.o
>    "vtable for RtMidiIn", referenced from:
>        __ZTV8RtMidiIn$non_lazy_ptr in RtMidi.cpp.o
>    "RtMidiOut::initialize()", referenced from:
>        RtMidiOut::RtMidiOut()in RtMidi.cpp.o
>        RtMidiOut::RtMidiOut()in RtMidi.cpp.o
>    "RtMidiIn::initialize()", referenced from:
>        RtMidiIn::RtMidiIn()in RtMidi.cpp.o
>        RtMidiIn::RtMidiIn()in RtMidi.cpp.o
>    "vtable for RtMidiOut", referenced from:
>        __ZTV9RtMidiOut$non_lazy_ptr in RtMidi.cpp.o
> ld: symbol(s) not found
> collect2: ld returned 1 exit status
> make[2]: *** [playsmf] Error 1
> make[1]: *** [CMakeFiles/playsmf.dir/all] Error 2
> make: *** [all] Error 2
> bin $

Can you check which symbols RtMidi.cpp.o contains ?
On Linux you could do this using nm, e.g. "nm -C filename.o". 

Alex


More information about the CMake mailing list