我用的makefile生成cmake的编译C ++文件依赖于提高文件系统库。
在关联过程中,我得到了以下错误:
Undefined symbols: "boost::system::get_generic_category()", referenced from: __static_initialization_and_destruction_0(int, int)in FaceRecognizer.cpp.o __static_initialization_and_destruction_0(int, int)in FaceRecognizer.cpp.o __static_initialization_and_destruction_0(int, int)in FaceRecognizer.cpp.o "boost::system::get_system_category()", referenced from: __static_initialization_and_destruction_0(int, int)in FaceRecognizer.cpp.o __static_initialization_and_destruction_0(int, int)in FaceRecognizer.cpp.o ld: symbol(s) not found collect2: ld returned 1 exit status make[2]: *** [src/ImageMarker] Error 1
从生成该错误生成文件的动作是这样的线:
cd /Users/janusz/Documents/workspace/ImageMarker/Debug/src && /opt/local/bin/cmake -E cmake_link_script CMakeFiles/ImageMarker.dir/link.txt --verbose=1 /usr/bin/c++ -O3 -Wall -Wno-deprecated -g -verbose -Wl,-search_paths_first -headerpad_max_install_names -fPIC CMakeFiles/ImageMarker.dir/ImageMarker.cpp.o CMakeFiles/ImageMarker.dir/Image.cpp.o CMakeFiles/ImageMarker.dir/utils.cpp.o CMakeFiles/ImageMarker.dir/XMLWriter.cpp.o CMakeFiles/ImageMarker.dir/FaceRecognizer.cpp.o -o ImageMarker -L/opt/local/lib ../libTinyXml.a /opt/local/lib/libboost_filesystem-mt.dylib
一些谷歌搜索给我看,这个错误似乎是与升压文件系统库的Mac电脑常见的,因为我必须对一个boost.system链接库或让我的项目取决于boost.system库。
如何强制cmake的没有硬编码库路径对库进行链接?
这里从otool的结果:
otool -L /opt/local/lib/libboost_filesystem-mt.dylib
/opt/local/lib/libboost_filesystem-mt.dylib:
/opt/local/lib/libboost_filesystem-mt.dylib (compatibility version 0.0.0, current version 0.0.0)
/opt/local/lib/libboost_system-mt.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0)
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.0.0)