I want to cross compile a simple main.cpp that uses boost libs (regex), The target plataform it's a raspberry pi (raspbian). I have installed from apt-get the libboost-all-dev package. So the headers were in the raspi.
Then from another tutorial, I was told to copy the /usr and /lib to my host system, throught rsync. So I copy to my host directory (/home/vitor/local/{usr,lib})
I have this 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})
The command used was:
cmake -DCMAKE_TOOLCHAIN_FILE=/home/vitor/bin/raspi/cmaketoolchain/toolchain.cmake ../src/
The cmake doesn't find the test lib. A ls in /home/vitor/usr/lib show me:
libboost_system.so
libboost_regex.so
libboost_unit_test_framework-mt.so
But no libboost_test.so was found.
Finnaly, this is the error I got:
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!
If I remove test from components required. The command works fine.
ps.: In my toolchain.cmake file, I was able to find the libs only with this two lines:
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
What can I do to find the libboost_test.so?
I don't think there's a boost target called just "test"; it should be "unit_test_framework" instead.
Try changing to:
find_package(Boost COMPONENTS system unit_test_framework regex REQUIRED)