似乎我无法看到明显的.我想为我的项目使用一些Boost库功能,并且知道我突然得到了这些好错误:
链接CXX可执行文件ATFOR CMakeFiles/ATFOR.dir/stdafx.cc.o:在函数
__static_initialization_and_destruction_0(int, int)': stdafx.cc:(.text+0x3c): undefined reference to
boost :: system :: generic_category()'stdafx.cc :(.text + 0x48 )中:对boost::system::generic_category()' stdafx.cc:(.text+0x54): undefined reference to
boost :: system :: system_category的未定义引用( )'CMakeFiles/ATFOR.dir/Main.cc.o:在函数__static_initialization_and_destruction_0(int, int)': Main.cc:(.text+0x29d): undefined reference to
boost :: system :: generic_category()'Main.cc :(.text + 0x2a9):未定义的引用boost::system::generic_category()' Main.cc:(.text+0x2b5): undefined reference to
boost :: system :: system_category()' collect2:错误:ld返回1退出状态
在这里你可以找到我的CMakeLists.txt,标题和主要内容:http
://pastie.org/8231509
正如你所看到的,我尝试了很多与CMakeLists一起玩,我很确定我拥有项目所需的所有标题.无论如何,我之前从未遇到过这样的错误,我真的很感激任何有关错误的建议/解决方案,因为我现在还没有任何想法.Thx提前.
Mar*_*cia 15
您必须明确添加系统库才能链接到您的程序中
find_package(Boost REQUIRED COMPONENTS system)
# ^^^^^^ this :)
Run Code Online (Sandbox Code Playgroud)
对于单独构建的其他Boost库(正则表达式,线程等)也必须这样做(参见此处).
ViR*_*iTy 13
链接阶段缺少"system"lib.我的配置如下,它修复了错误:
find_package(Boost 1.55.0 REQUIRED COMPONENTS system filesystem)
include_directories(... ${Boost_INCLUDE_DIRS})
link_directories(... ${Boost_LIBRARY_DIRS})
target_link_libraries(... ${Boost_LIBRARIES})
Run Code Online (Sandbox Code Playgroud)
请注意,仅使用
find_package(Boost 1.55.0 REQUIRED)
Run Code Online (Sandbox Code Playgroud)
不起作用,因为${Boost_LIBRARIES}
将无法使用.
好吧,对于那些感兴趣的人来说,Mark Garcia的答案是一个很好的电话,但更重要的是你需要明确地将你想要的lib链接起来像
TARGET_LINK_LIBRARIES(ATFOR $ {OpenCV_LIBS} curl $ {Boost_SYSTEM_LIBRARY} $ {Boost_FILESYSTEM_LIBRARY})
我尝试和阅读的所有其他选项对我没有用,不知道为什么,但我希望这有助于某人.
归档时间: |
|
查看次数: |
14959 次 |
最近记录: |