我正在使用 cmake 2.8.9、g++ 3.4.4 和 Boost 1.50。在 Windows 8 64 位上的 Cygwin 中。这是我收到的错误消息。
链接 CXX 可执行文件 RayTracer.exe CMakeFiles/RayTracer.dir/Ray_Tracer.cpp.o:Ray_Tracer.cpp:(.text+0x89c): undefined reference to
boost::system::generic_category()' CMakeFiles/RayTracer.dir/Ray_Tracer.cpp.o:Ray_Tracer.cpp:(.text+0x8a6): undefined reference to
boost::system::generic_category()' CMakeFiles/RayTracer.dir/Ray_Tracer。 cpp.o:Ray_Tracer.cpp:(.text+0x8b0): undefined reference toboost::system::system_category()' /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld: CMakeFiles/RayTracer.dir/Ray_Tracer.cpp.o: bad reloc address 0xb in section
.text$_ZN5boost6system14error_categoryD1Ev[boost::system::error_category::~error_category()]' collect2: ld 返回 1 退出状态 CMakeFiles/RayTracer.dir /build.make:94: 目标RayTracer.exe' failed make[2]: *** [RayTracer.exe] Error 1 CMakeFiles/Makefile2:64: recipe for target
CMakeFiles/RayTracer.dir/all' 的配方失败 make[1]: * [CMakeFiles/RayTracer.dir/all] 错误 2 Makefile:75: 目标 `all' 的配方失败 make: * [全部] 错误 2
从我所见,通常的问题是无法链接升压系统库,但我确保这样做。这是我的 CMakeLists.txt 文件的相关部分:
#Edit: cmake can't find the static libraries on cygwin, so I'm setting this to false for now.
SET(Boost_USE_STATIC_LIBS FALSE)
FIND_PACKAGE(Boost 1.50 REQUIRED date_time program_options thread filesystem system unit_test_framework)
IF(${Boost_FOUND})
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
ENDIF()
add_executable(RayTracer
Ray_Tracer.cpp
)
target_link_libraries(RayTracer ${Boost_PROGRAM_OPTIONS_LIBRARIES})
这是我的 .cpp 文件中触发错误的行:
#include <boost/filesystem.hpp>
知道我做错了什么吗?