在Linux Mint上使用CMake找不到提升 [英] Cannot find boost with CMake on Linux Mint

查看:170
本文介绍了在Linux Mint上使用CMake找不到提升的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用C ++开发库,尝试将boost集成到我的项目时遇到了一些困难.我留下了无法找到boost的信息,但是另一方面,我使用Arch的开发人员也没有问题.

I have been working on a library in C++ and have run into a bit of difficulty trying to integrate boost into my project. I kept the message that boost could not be found, but on the other hand, my fellow developer using Arch had no issues.

我们发现这是因为Linux Mint(至少带有libboost-all-dev软件包)将库安装到/usr/lib/x86_64-linux-gnu,而FindBoost模块未搜索这些库.我们通过创建符号链接来解决此问题:

We figured out that this is because Linux Mint (at least with the libboost-all-dev package) installs the libraries to /usr/lib/x86_64-linux-gnu which is not searched by the FindBoost module. We fixed this by creating symbolic links:

ln -s /usr/lib/x86_64-linux-gnu/libboost* /usr/lib/

我想知道的是:有没有一种更好的(更可接受的)方法来解决此问题,因为当我编译大型项目时,我不会遇到这个问题.

What I want to know: is there a better (more acceptable) way of fixing this because when I compile major projects, I do not run into this problem.

这是CMakeLists.txt(有一些遗漏)

Here is CMakeLists.txt (with some omissions)

cmake_minimum_required(VERSION 2.8)
project(testlibrary CXX)

set(CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS}")

set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED OFF)
set(Boost_USE_STATIC_RUNTIME OFF)

find_package(Boost 1.55.0 COMPONENTS unit_test_framework thread log REQUIRED)

include_directories(${Boost_INCLUDE_DIRS})

add_library(testlibrary STATIC ${SOURCE_MAIN})

target_link_libraries(testlibrary ${Boost_LIBRARIES})

推荐答案

您可以设置提示BOOST_LIBRARYDIR:

set(BOOST_LIBRARYDIR "/usr/lib/x86_64-linux-gnu")
find_package(Boost 1.55.0 COMPONENTS unit_test_framework thread log REQUIRED)

或者,您可以在运行CMake时进行如下设置:

Alternative, you can set this when running CMake like this:

cmake -DBOOST_LIBRARYDIR="/usr/lib/x86_64-linux-gnu" <project_root>

如果您只是运行:

cmake <project_root>

然后FindBoost.cmake将在通常的位置查看您的增强库.

then FindBoost.cmake will look in the usual spots for your boost libaries.

请参阅FindBoost.cmake的文档以获取您的CMake版本此处.

See the documentation of FindBoost.cmake for your CMake version here.

这篇关于在Linux Mint上使用CMake找不到提升的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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