cmake和boost信号的问题
problems with cmake and boost-signals
我使用cmake的项目与boost,我已经设置了所需的boost信号和cmake状态找到它,但当我编译项目我得到一个链接错误。
我可以解决它与链接器指令集(CMAKE_EXE_LINKER_FLAGS -lboostrongignals),但是这似乎与它应该做的相反。有人能建议一个更好的方法吗?由于
在CMakeLists.txt IF(UNIX)
find_package(Boost COMPONENTS system filesystem random regex signals thread program_options date_time REQUIRED)
INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIRS} )
ENDIF()
运行cmake:
$ cmake ../
-- Boost version: 1.49.0
-- Found the following Boost libraries:
-- system
-- filesystem
-- random
-- regex
-- signals
-- thread
-- program_options
-- date_time
-- Configuring done
-- Generating done
-- Build files have been written to: /home/me/myproject/build
链接器错误:
/usr/bin/ld: /usr/local/lib/libwt.so: undefined reference to symbol '_ZN5boost7signals9trackableD2Ev'
/usr/bin/ld: note: '_ZN5boost7signals9trackableD2Ev' is defined in DSO /usr/lib/libboost_signals.so.1.49.0 so try adding it to the linker command line
/usr/lib/libboost_signals.so.1.49.0: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
Boost Signals不是一个头文件库。除了给出包含目录,你还需要告诉CMake链接到它。
add_executable(MyProgram [...] )
target_link_libraries(MyProgram ${Boost_LIBRARIES})
如果你也打算在Windows上构建,你可能还想禁用自动链接:
add_definitions(-DBOOST_ALL_NO_LIB)
注意Boost Signals已经被弃用,并被Signals2取代,Signals2实际上是一个头文件库。如果由您来做选择,可以考虑使用Signals2。
相关文章:
- 代码在我的计算机上运行良好,但是在将其提交给coursera时遇到未知的信号11问题
- Qt 信号/插槽问题
- 使用 sv hup SIGHUP 信号重新加载配置时出现问题
- 信号槽自定义结构问题
- 从 Qt 中的信号调用成员函数的问题
- Qt的新信号/时隙语法问题 - 连接到一个简单的函数
- 将组合框信号连接到 Qt 中的 std::function 时出现问题
- QML:收到C 信号从C 传递时刷新问题
- 这个餐饮哲学家问题(dpp)的解决方案是如何工作的?互斥体和信号量
- QlineEdit的信号映射问题
- 在使用 pthread 和信号量实现生产者-消费者问题时需要帮助
- 从主线程向workersread发出信号时出现问题
- 信号量的问题
- 我在Qt信号和插槽问题上的错误在哪里?
- QT 信号插槽问题。发出信号,不调用时隙。没有警告,没有错误,没有消息
- 带有信号的ThreadSafe Singleton的问题
- 如何用单个信号处理程序解决这个多linux定时器的问题
- 问题5.2:QLocalServer接收重复的readyRead信号
- 从Wt小部件信号事件运行popen()时出现问题
- NDK:0xdeadd00d时虚拟机中止和致命信号 11 (SIGSEGV) 的问题(代码 = 1)