cmake找不到boost lib

时间:2013-06-03 18:40:57

标签: boost cmake raspberry-pi boost-test

我想交叉编译一个使用boost libs(regex)的简单main.cpp,目标plataform它是一个覆盆子pi(raspbian)。我从apt-get安装了libboost-all-dev软件包。所以标题是在raspi。

然后从另一个教程中,我被告知通过rsync将/ usr和/ lib复制到我的主机系统。所以我复制到我的主机目录(/ home / vitor / local / {usr,lib})

我有这个CMakeLists.txt

cmake_minimum_required(VERSION 2.8)
project(BoostRegex)

set(Boost_ADDITIONAL_VERSIONS "1.49" "1.49.0" )
set(BOOST_ROOT /home/vitor/local/usr/lib)
set(BOOST_INCLUDEDIR /home/vitor/local/usr/include)
set(BOOST_LIBRARYDIR /home/vitor/local/usr/lib)

add_definitions(-DBOOST_ALL_NO_LIB)

find_package(Boost COMPONENTS system test regex REQUIRED)

message(status " ** Boost Root: ${BOOST_ROOT} **")
message(status " ** Boost Include: ${BOOST_INCLUDEDIR} **")
message(status " ** Boost Libraries Dirs: ${BOOST_LIBRARY_DIRS} **")
message(status " ** Boost Librraries: ${BOOST_LIBRARYDIR} **")

include_directories(${BOOST_INCLUDEDIR})
link_directories(${BOOST_LIBRARYDIR})

add_executable(BoostRegex BoostRegex.cpp)
target_link_libraries(BoostRegex ${Boost_LIBRARIES})

使用的命令是:

cmake -DCMAKE_TOOLCHAIN_FILE=/home/vitor/bin/raspi/cmaketoolchain/toolchain.cmake ../src/

cmake找不到测试库。 / home / vitor / usr / lib中的ls告诉我:

libboost_system.so
libboost_regex.so
libboost_unit_test_framework-mt.so

但是没有找到libboost_test.so。

Finnaly,这是我得到的错误:

Unable to find the requested Boost libraries.
Boost version: 1.49.0
Boost include path: /home/vitor/local/usr/include
The following Boost libraries could not be found:

      boost_test

Some (but not all) of the required Boost libraries were found.  You may
need to install these additional Boost libraries.  Alternatively, set
BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT
to the location of Boost.
Call Stack (most recent call first):
   CMakeLists.txt:12 (find_package)


 status ** Boost Root: /home/vitor/local/usr/lib **
 status ** Boost Include: /home/vitor/local/usr/include **
 status ** Boost Libraries Dirs:  **
 status ** Boost Librraries: /home/vitor/local/usr/lib **
 -- Configuring incomplete, errors occurred!

如果我从所需的组件中删除测试。该命令工作正常。

ps。:在我的toolchain.cmake文件中,我只能用这两行找到libs:

SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)

如何找到libboost_test.so?

1 个答案:

答案 0 :(得分:3)

我不认为有一个称为“测试”的提升目标;它应该是“unit_test_framework”而不是。

尝试更改为:

find_package(Boost COMPONENTS system unit_test_framework regex REQUIRED)