On 3/8/07, Pierre Malarme <[EMAIL PROTECTED]> wrote:
I have a problem using Xerces-C++ with cmake. I'm on Mac OS X 10.4.8 with an Intel Core 2 Duo. I try to compile a parser.cpp file with nothing more that includes that i need. When i do so, i have this error message in return :[100%] Building CXX object CMakeFiles/Dom.dir/parser.o Linking CXX executable Dom /usr/bin/ld: Undefined symbols: xercesc_2_7::DTDEntityDecl::serialize(xercesc_2_7::XSerializeEngine&) xercesc_2_7::XMLAttDefList::serialize(xercesc_2_7::XSerializeEngine&) xercesc_2_7::XMLEntityDecl::~XMLEntityDecl() xercesc_2_7::SAXParseException::SAXParseException(xercesc_2_7::SAXParseException const&) xercesc_2_7::SAXParseException::~SAXParseException() xercesc_2_7::XMemory::operator delete(void*) xercesc_2_7::DTDEntityDecl::getProtoType() const xercesc_2_7::DTDEntityDecl::isSerializable() const xercesc_2_7::XMLAttDefList::getProtoType() const xercesc_2_7::XMLAttDefList::isSerializable() const xercesc_2_7::PSVIItem::getActualValue() const typeinfo for xercesc_2_7::XMLEntityDecl typeinfo for xercesc_2_7::SAXParseException collect2: ld returned 1 exit status make[2]: *** [Dom] Error 1 make[1]: *** [CMakeFiles/Dom.dir/all] Error 2 make: *** [all] Error 2 My FindXerces.cmake file is : #SET THE ROOT DIRECTORY WHERE XERCES-C++ IS INSTALLED SET(XERCES_ROOT_DIR /Developer/CPP/xerces-c-src_2_7_0) #DO NOT CHANGE SET(XERCES_LIBRARY_DIR ${XERCES_ROOT_DIR}/lib) SET(XERCES_INCLUDE_DIR ${XERCES_ROOT_DIR}/include) SET(XERCES_LINK_FLAGS -L${XERCES_LIBRARY_DIR}) SET(XERCES_INC_FLAGS -I${XERCES_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${XERCES_INCLUDE_DIR}) LINK_DIRECTORIES(${XERCES_LIBRARY_DIR}) LINK_LIBRARIES(${XERCES_LINK_FLAGS}) ADD_DEFINITIONS(${XERCES_INC_FLAGS}) and my CMakeLists.txt file is : PROJECT(Dom) INCLUDE (FindXerces.cmake) SET(SRCS parser.cpp) ADD_Executable(Dom ${SRCS})
Hi Pierre, In the documentation of the `LINK_LIBRARIES' command, it is specified that: 1. The libraries are linked with all targets defined in *sub-directories*. In another words, it means that the ADD_EXECUTABLE call in the main CMakeLists.txt file might not consider it. 2. The parameters are targets defined with ADD_EXECUTABLE or ADD_LIBRARY. So I guess CMake should shiek. By the way,: 1. the LINK_DIRECTORIES command is more or less deprecated, you should use the TARGET_LINK_LIBRARIES command instead: 2. The way you search the library is very static. You should maybe use the command FIND_LIBRARY and FIND_PATH instead. Here is a very simple CMake module which uses these 2 commands: http://www.cmake.org/cgi-bin/viewcvs.cgi/Modules/FindTIFF.cmake?rev=1.9&root=CMake&view=markup You can then set the environment variables CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH to provide to CMake another directories to look for includes, respectively libraries so that everything is found automagically. PROJECT(Dom) INCLUDE (FindXerces.cmake) SET(SRCS parser.cpp) INCLUDE_DIRECTORIES(${XERCES_INCLUDE_DIR}) ADD_DEFINITIONS(${XERCES_INC_FLAGS}) ADD_Executable(Dom ${SRCS}) TARGET_LINK_LIBRARIES(Dom ${XERCES_LIBRARY_DIR}) If you still have troubles, could you please submit the compilation log with the variable CMAKE_VERBOSE_MAKEFILE set to true? $ cmake -DCMAKE_VERBOSE_MAKEFILE=true $ make # thx -- Tristan Carel Music with dinner is an insult both to the cook and the violinist. http://www.tristan-carel.com _______________________________________________ CMake mailing list [email protected] http://www.cmake.org/mailman/listinfo/cmake
