3

我想交叉编译一个使用 boost 库(正则表达式)的简单 main.cpp,目标平台是树莓派(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 文件中,我只能用这两行找到库:

SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)

我该怎么做才能找到 libboost_test.so?

4

1 回答 1

3

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

尝试更改为:

find_package(Boost COMPONENTS system unit_test_framework regex REQUIRED)
于 2013-06-04T08:10:55.687 回答