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:

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':                          
                   
/home/dagg/workspace/OSSM/src/DataObjects/CWorld.hpp:30: undefined reference to 
`Array<Nation*>::~Array()'                                                      
                                      
/home/dagg/workspace/OSSM/src/DataObjects/CWorld.hpp:30: undefined reference to 
`Array<City*>::~Array()'                                                        
                                      
/home/dagg/workspace/OSSM/src/DataObjects/CWorld.hpp:30: undefined reference to 
`Array<Continent*>::~Array()'                                                   
                                      
/home/dagg/workspace/OSSM/src/DataObjects/CWorld.hpp:30: undefined reference to 
`Array<Competition*>::~Array()'                                                 
                                      
/home/dagg/workspace/OSSM/src/DataObjects/CWorld.hpp:30: undefined reference to 
`Array<Team*>::~Array()'                                                        
                                      
CMakeFiles/ossm.dir/COssm.cpp.o: In function `Ossm::cleanUp()':                 
                   
/home/dagg/workspace/OSSM/src/COssm.cpp:44: undefined reference to 
`Array<bool>::~Array()'         
/home/dagg/workspace/OSSM/src/COssm.cpp:44: undefined reference to 
`Array<bool>::~Array()'         
CMakeFiles/ossm.dir/COssm.cpp.o: In function `~World':                          
                   
/home/dagg/workspace/OSSM/src/DataObjects/CWorld.hpp:30: undefined reference to 
`Array<Team*>::~Array()'                                                        
                                      
/home/dagg/workspace/OSSM/src/DataObjects/CWorld.hpp:30: undefined reference to 
`Array<Competition*>::~Array()'                                                 
                                      
/home/dagg/workspace/OSSM/src/DataObjects/CWorld.hpp:30: undefined reference to 
`Array<Continent*>::~Array()'                                                   
                                      
/home/dagg/workspace/OSSM/src/DataObjects/CWorld.hpp:30: undefined reference to 
`Array<City*>::~Array()'                                                        
                                      
./build/libs/libThreads.so: undefined reference to 
`boost::iostreams::detail::bzip2_base::~bzip2_base()'                           
                                                                  
./build/libs/libUtilities.so: undefined reference to 
`DataFactory::~DataFactory()'                
./build/libs/libDataObjects.so: undefined reference to 
`Array<Stadium*>::Array()'                 
./build/libs/libUtilities.so: undefined reference to 
`Array<std::basic_string<char, std::char_traits<char>, std::allocator<char> > 
>::operator[](int)'                                               
./build/libs/libUtilities.so: undefined reference to `Array<Staff*>::size() 
const'                
./build/libs/libDataObjects.so: undefined reference to 
`Array<Nation*>::Array()'                  
./build/libs/libUtilities.so: undefined reference to `Array<City*>::Array(int)' 
                  
./build/libs/libUtilities.so: undefined reference to `Array<Staff*>::~Array()'  
                  
./build/libs/libUtilities.so: undefined reference to `Array<Continent*>::size() 
const'            
./build/libs/libThreads.so: undefined reference to `vtable for 
StaffSaverThread'                  
./build/libs/libUtilities.so: undefined reference to `vtable for Utils'         
                  
./build/libs/libDataObjects.so: undefined reference to `Array<unsigned 
char>::Array(int)'         
./build/libs/libUtilities.so: undefined reference to 
`Array<std::basic_string<char, std::char_traits<char>, std::allocator<char> > 
>::size() const'                                                  
./build/libs/libDataObjects.so: undefined reference to 
`Array<std::basic_string<char, std::char_traits<char>, std::allocator<char> > 
>::~Array()'                                                    
./build/libs/libThreads.so: undefined reference to 
`boost::iostreams::detail::bzip2_base::end(bool)'                               
                                                                  
./build/libs/libThreads.so: undefined reference to `vtable for 
DataLoaderThread'                  
./build/libs/libThreads.so: undefined reference to 
`boost::iostreams::bzip2::finish'              
./build/libs/libUtilities.so: undefined reference to `Array<int>::~Array()'     
                  
./build/libs/libUtilities.so: undefined reference to `vtable for Base64Encoder' 
                  
./build/libs/libDataObjects.so: undefined reference to `Array<unsigned 
char>::~Array()'           
./build/libs/libUtilities.so: undefined reference to 
`Array<Competition*>::Array(int)'            
./build/libs/libDataObjects.so: undefined reference to `Array<unsigned 
short>::~Array()'          
./build/libs/libThreads.so: undefined reference to `vtable for DataSaverThread' 
                  
./build/libs/libUtilities.so: undefined reference to `vtable for Base64Decoder' 
                  
./build/libs/libUtilities.so: undefined reference to `Array<unsigned 
char>::operator[](int)'      
./build/libs/libThreads.so: undefined reference to 
`boost::iostreams::detail::bzip2_base::decompress()'                            
                                                                  
./build/libs/libThreads.so: undefined reference to 
`boost::iostreams::bzip2::stream_end'          
./build/libs/libThreads.so: undefined reference to 
`boost::iostreams::bzip2_error::check(int)'    
./build/libs/libDataObjects.so: undefined reference to 
`Array<Competition*>::Array()'             
./build/libs/libUtilities.so: undefined reference to `Array<City*>::size() 
const'                 
./build/libs/libUtilities.so: undefined reference to 
`Array<Team*>::operator[](int)'              
./build/libs/libThreads.so: undefined reference to 
`boost::iostreams::detail::bzip2_base::after(char const*&, char*&)'             
                                                                  
./build/libs/libUtilities.so: undefined reference to 
`Array<Continent*>::operator[](int)'         
./build/libs/libUtilities.so: undefined reference to `Array<Team*>::size() 
const'                 
./build/libs/libUtilities.so: undefined reference to 
`Array<Staff*>::Array(int)'                  
./build/libs/libThreads.so: undefined reference to `vtable for GameThread'      
                  
./build/libs/libDataObjects.so: undefined reference to `Array<unsigned 
short>::Array(int)'        
./build/libs/libDataObjects.so: undefined reference to `Array<int>::Array()'    
                  
./build/libs/libUtilities.so: undefined reference to 
`Array<City*>::operator[](int)'              
./build/libs/libUtilities.so: undefined reference to 
`Array<Competition*>::operator[](int)'       
./build/libs/libThreads.so: undefined reference to `vtable for 
StaffLoaderThread'                 
./build/libs/libThreads.so: undefined reference to 
`boost::iostreams::detail::bzip2_base::do_init(bool, void* (*)(void*, int, 
int), void (*)(void*, void*), void*)'                                  
./build/libs/libDataObjects.so: undefined reference to 
`Array<std::basic_string<char, std::char_traits<char>, std::allocator<char> > 
>::Array(int)'                                                  
./build/libs/libUtilities.so: undefined reference to 
`Array<Competition*>::size() const'          
./build/libs/libDataObjects.so: undefined reference to `Array<Team*>::Array()'  
                  
./build/libs/libThreads.so: undefined reference to 
`boost::iostreams::detail::bzip2_base::bzip2_base(boost::iostreams::bzip2_params
 const&)'                                                         
./build/libs/libDataObjects.so: undefined reference to `Array<int>::Array(int)' 
                  
./build/libs/libUtilities.so: undefined reference to 
`Array<Continent*>::Array(int)'              
./build/libs/libThreads.so: undefined reference to `Array<unsigned 
char>::~Array()'               
./build/libs/libUtilities.so: undefined reference to `Utils::~Utils()'          
                  
./build/libs/libThreads.so: undefined reference to `vtable for 
DataLinkerThread'                  
./build/libs/libUtilities.so: undefined reference to 
`Array<Staff*>::operator[](int)'
./build/libs/libThreads.so: undefined reference to 
`boost::iostreams::detail::bzip2_base::before(char const*&, char const*, 
char*&, char*)'
./build/libs/libThreads.so: undefined reference to 
`boost::iostreams::detail::bzip2_base::compress(int)'
./build/libs/libDataObjects.so: undefined reference to `Array<City*>::Array()'
./build/libs/libUtilities.so: undefined reference to `Array<Team*>::Array(int)'
./build/libs/libUtilities.so: undefined reference to `vtable for DataFactory'
./build/libs/libThreads.so: undefined reference to `Array<unsigned 
char>::size() const'
./build/libs/libThreads.so: undefined reference to 
`boost::iostreams::bzip2::run'
collect2: ld returned 1 exit status
make[2]: *** [build/ossm] Error 1
make[2]: Leaving directory `/home/dagg/workspace/OSSM'
make[1]: *** [src/CMakeFiles/ossm.dir/all] Error 2
make[1]: Leaving directory `/home/dagg/workspace/OSSM'
make: *** [all] Error 2

here is my cmakelist.txt:
#this is just a basic CMakeLists.txt, for more information see the cmake manpage

#add definitions, compiler switches, etc.
ADD_DEFINITIONS(-g -Wall -O2)

#get all cpp files in libs
file(GLOB UTIL_CPP Utilities/*.cpp)
file(GLOB DATA_CPP DataObjects/*.cpp)
file(GLOB THREADS_CPP Threads/*.cpp)
#file(GLOB TESTUNITS_CPP testUnits/Threads/*.cpp testUnits/Utils/*.cpp)

#build a shared library
ADD_LIBRARY(Utilities SHARED ${UTIL_CPP}) 
ADD_LIBRARY(DataObjects SHARED ${DATA_CPP}) 
ADD_LIBRARY(Threads SHARED ${THREADS_CPP})

#add_subdirectory(testUnits)
#link libs
target_link_libraries(Utilities ${Boost_LIBRARIES})
target_link_libraries(DataObjects ${Boost_LIBRARIES} Utilities)
target_link_libraries(Threads ${Boost_LIBRARIES} Utilities)

#list all source files here
ADD_EXECUTABLE(ossm COssm.cpp)

#need to link to some other libraries
TARGET_LINK_LIBRARIES(ossm DataObjects Utilities Threads)

#add an install target here
#INSTALL_FILES(...)
#INSTALL_PROGRAMS(...)
#INSTALL_TARGET(...)

last but not least, here is the content of each lib in terms for code files:
src/DataObjects:
CArray.cpp      
CArray.hpp      
CCity.cpp       
CCity.hpp       
CCompetition.cpp
CCompetition.hpp
CContinent.cpp  
CContinent.hpp  
CDataSharedIncludes.hpp
CFormation.hpp         
CLanguage.cpp          
CLanguage.hpp          
CLinkBatch.cpp         
CLinkBatch.hpp         
CNation.cpp            
CNation.hpp            
CStaff.cpp             
CStaff.hpp             
CTaskInterface.hpp     
CTeam.cpp              
CTeam.hpp              
CTrainingActivity.hpp  
CWorld.hpp             

src/Threads:
CDataLinkerThread.cpp
CDataLinkerThread.hpp
CDataLoaderThread.cpp
CDataLoaderThread.hpp
CDataSaverThread.cpp 
CDataSaverThread.hpp 
CGameThread.cpp      
CGameThread.hpp      
CStaffLoaderThread.cpp
CStaffLoaderThread.hpp
CStaffSaverThread.cpp
CStaffSaverThread.hpp

src/Utilities:
CBase64Decoder.cpp
CBase64Decoder.hpp
CBase64Encoder.cpp
CBase64Encoder.hpp
CDataFactory.cpp
CDataFactory.hpp
CThreadPool.cpp
CThreadPool.hpp
CUtils.cpp
CUtils.hpp

how can I solve the problem? if more data is needed, then say so and I'll post 
it.

thanks.


_______________________________________________
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

Reply via email to