[CMake] getting undefined error to my own libs.

Eric Noulard eric.noulard at gmail.com
Tue Dec 29 08:42:42 EST 2009


2009/12/29 eial at cs.bgu.ac.il <eial at cs.bgu.ac.il>:
> hello.
> I'm writing a c++ program that uses three shared libs that I wrote, for some reason, when it gets to the main cpp file, it fails with undefined error. here is the error report:

Concerning the link error [apparently] related to boost usage I let
Boost+CMake user
help you.

Concerning the first errors related to your templated Array<T> class
how did you split your
CArray.cpp
CArray.hpp
files?

Since CArray seems to be a templated class I bet the CArray.hpp contains
the code and/or includes CArray.cpp ?

If not you should ensure that the (template) instance of class you are
using in your
main program are instantiated in the DataObject library if not you may
get missing
symbols like the one you get here:

> Linking CXX executable ../build/ossm
> cd /home/dagg/workspace/OSSM/src && /usr/bin/cmake -E cmake_link_script CMakeFiles/ossm.dir/link.txt --verbose=1
> /usr/bin/c++     -fPIC CMakeFiles/ossm.dir/COssm.cpp.o  -o ../build/ossm -rdynamic ../build/libs/libDataObjects.so ../build/libs/libUtilities.so ../build/libs/libThreads.so ../build/libs/libUtilities.so -lboost_thread-mt -lboost_unit_test_framework-mt -Wl,-rpath,/home/dagg/workspace/OSSM/build/libs
> CMakeFiles/ossm.dir/COssm.cpp.o: In function `Ossm::cleanUp()':
> /home/dagg/workspace/OSSM/src/COssm.cpp:33: undefined reference to `Array<bool>::Array(int)'
> /home/dagg/workspace/OSSM/src/COssm.cpp:35: undefined reference to `Array<bool>::operator[](int)'
> /home/dagg/workspace/OSSM/src/COssm.cpp:39: undefined reference to `Array<bool>::operator[](int)'
> CMakeFiles/ossm.dir/COssm.cpp.o: In function `~World':

[...]

-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org


More information about the CMake mailing list