[CMake] Linking problems
John Dey
jsdey at optonline.net
Thu Apr 16 18:53:26 EDT 2009
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 $
On Apr 16, 2009, at 3:53 PM, Alexander Neundorf wrote:
> On Thursday 16 April 2009, John Dey wrote:
>> Hi List,
>>
>> I am getting undefined symbols while linking up a program that I can
>> create by hand (details shown below). I think I have set cmake to
>> duplicate but it can't find symbols. Any help would be greatly
>> appreciated. Thanks.
>>
>> John
>>
>> Hand compile and link:
>>
>>
>> g++ -O3 -Wall -g -D__GXX__ -D__LITTLE_ENDIAN__ -D__MACOSX_CORE__ -c
>> Stk.cpp -o Release/Stk.o
>> g++ -O3 -Wall -g -D__GXX__ -D__LITTLE_ENDIAN__ -D__MACOSX_CORE__ -c
>> MidiFileIn.cpp -o Release/MidiFileIn.o
>> g++ -O3 -Wall -g -D__GXX__ -D__LITTLE_ENDIAN__ -D__MACOSX_CORE__ -c
>> RtMidi.cpp -o Release/RtMidi.o
>> g++ -O3 -Wall -g -D__GXX__ -D__LITTLE_ENDIAN__ -D__MACOSX_CORE__ -o
>> playsmf playsmf.cpp Release/Stk.o Release/MidiFileIn.o Release/
>> RtMidi.o -lpthread -lm -framework CoreAudio -framework
>> CoreFoundation
>> -framework CoreMidi
>>
>> CMakeLists.txt:
>>
>> project (playsmf)
>> cmake_minimum_required(VERSION 2.6)
>> add_definitions(-D__LITTLE_ENDIAN__ -D__MACOS_CORE__ -D__GXX__ -g -
>> Wall -03)
>
>
> You mean "-O3", not "-03", right ?
>
>
>> include_directories("${PROJECT_SOURCE_DIR}")
>> add_executable(playsmf playsmf.cpp MidiFileIn.cpp RtMidi.cpp Stk.cpp)
>> find_library(COREAUDIO CoreAudio "/usr")
>> find_library(COREFOUNDATION CoreFoundation "/")
>> find_library(COREMIDI CoreMidi "/")
>> find_library(PTHREAD pthread "/")
>> find_library(M m "/")
>> target_link_libraries(playsmf ${COREAUDIO} ${COREFOUNDATION}
>> ${COREMIDI} ${PTHREAD} ${M}
>> )
>>
>> Error messages:
>>
>> Linking CXX executable playsmf
>> Undefined symbols:
>> "RtMidiOut::initialize()", referenced from:
>> RtMidiOut::RtMidiOut()in RtMidi.cpp.o
>> "RtMidiOut::sendMessage(std::vector<unsigned char,
>> std::allocator<unsigned char> >*)", referenced from:
>> _main in playsmf.cpp.o
>> _main in playsmf.cpp.o
>> "vtable for RtMidiOut", referenced from:
>> __ZTV9RtMidiOut$non_lazy_ptr in RtMidi.cpp.o
>> "vtable for RtMidiIn", referenced from:
>> __ZTV8RtMidiIn$non_lazy_ptr in RtMidi.cpp.o
>> "RtMidiIn::initialize()", referenced from:
>> RtMidiIn::RtMidiIn()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
>
> Can you please post the output of "make VERBOSE=1" so we can see the
> actual
> link command ?
>
> There seems to be a problem with RtMidi.cpp. I guess the functions
> which it
> doesn't find do indeed exist in RtMidi.cpp ?
>
> Alex
>> http://www.cmake.org/mailman/listinfo/cmake
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
More information about the CMake
mailing list