升压日志,GCC 4.4和CMake的 [英] Boost log, GCC 4.4 and CMake

查看:216
本文介绍了升压日志,GCC 4.4和CMake的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让使用GCC 4.4.5,2.8.2的CMake和Boost 1.53.0在Linux上运行一个简单的例子boost.log

I am trying to get a simple boost.log example running on Linux using GCC 4.4.5, CMake 2.8.2 and Boost 1.53.0.

编译升压和升压日志成功,但我的连接测试程序boost.log时,我不断收到的问题。

Compiling boost and boost log succeeded, but I keep getting issues when linking my test program to boost.log.

我用下面的CMakeLists.txt文件:

I use the following CMakeLists.txt file:

cmake_minimum_required(VERSION 2.8)

project(QuantibBoostLogTest)

# Include boost headers
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
find_package(Threads)
find_package(Boost 1.53.0 COMPONENTS thread date_time filesystem system log log_setup REQUIRED)
if(Boost_FOUND)
  include_directories( ${Boost_INCLUDE_DIRS} )
  link_libraries(${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
else(Boost_FOUND)
  message(FATAL_ERROR "Cannot build Quantib Boost Log test without Boost. Please set Boost_DIR.")
endif(Boost_FOUND)

add_executable(quantibBoostLogTest boost_log_test.cxx)
install(TARGETS quantibBoostLogTest DESTINATION .)

CMake的不正确检测Boost库,但我仍然得到链接错误,主要的形式:

CMake does detect the boost libraries correctly, but I still get linker errors, mostly of the form:

core.cpp:(.text+0x1b0e): undefined reference to `boost::detail::get_tss_data(void const*)'

我做链接线程库。是否有人知道如何解决此问题?

I do link the thread libraries. Does anybody know how to solve this?

推荐答案

好像boost.log取决于boost.thread库则需要更改库的顺序。请参见为什么链接顺序此事确实

It seems like boost.log depends on boost.thread library then you need change order of libraries. See why link order does matter

试试下面的顺序

find_package(Boost 1.53.0 COMPONENTS log log_setup thread date_time filesystem system REQUIRED)

如果它不会帮助尝试包括他们两次如下

if it will not help try include them two times as following

link_libraries(${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${Boost_LIBRARIES})

这篇关于升压日志,GCC 4.4和CMake的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆