I try to set up my cross-platform development environment with CMake.
I encounter the following error only when I try to compile with poky toolchain:
make[2]: * No rule to make '/opt/poky/1.3/sysroots/armv5te-poky-linux-gnueabi/usr/lib/libboost_thread.so', needed by 'test'. Stop
I tried to set up the CMake toolchain in two different methods and the result is the same.
Method1 (simple):
###################################################################################
# Cross compile using Poky prebuilt toolchains, you need to source the
# environment first:
#
# $ rm -fr build; mkdir build; cd build
# $ source /opt/poky/1.3/environment-setup-armv5te-poky-linux-gnueabi
# $ cmake -DCMAKE_TOOLCHAIN_FILE=Toolchains/arm-poky-linux-gnueabi-simple.cmake
# $ make
###################################################################################
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_VERSION 1)
SET(CMAKE_FIND_ROOT_PATH $ENV{OECORE_TARGET_SYSROOT})
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
Method2:
# this one is important
SET( CMAKE_SYSTEM_NAME Linux )
# this one not so much
SET( CMAKE_SYSTEM_VERSION 1 )
# specify the cross compiler
SET( CROSS_COMPILER_PATH /opt/poky/1.3/sysroots/x86_64-pokysdk-linux/usr/bin/armv5te-poky-linux-gnueabi )
SET( C_CROSS_COMPILER arm-poky-linux-gnueabi- )
FIND_PROGRAM( CCACHE ccache )
IF( CCACHE )
SET( CMAKE_C_COMPILER "${CCACHE}" "${CROSS_COMPILER_PATH}/${C_CROSS_COMPILER}gcc" )
SET( CMAKE_CXX_COMPILER "${CCACHE}" "${CROSS_COMPILER_PATH}/${C_CROSS_COMPILER}g++" )
ELSE( CCACHE )
SET( CMAKE_C_COMPILER "${CROSS_COMPILER_PATH}/${C_CROSS_COMPILER}gcc" "" )
SET( CMAKE_CXX_COMPILER "${CROSS_COMPILER_PATH}/${C_CROSS_COMPILER}g++" "" )
ENDIF(CCACHE)
SET( CMAKE_RANLIB "${CROSS_COMPILER_PATH}/${C_CROSS_COMPILER}ranlib" )
SET( CMAKE_AR "${CROSS_COMPILER_PATH}/${C_CROSS_COMPILER}ar" )
SET( CMAKE_COMPILER_IS_GNUCC 1 )
SET( CMAKE_COMPILER_IS_GNUCXX 1 )
INCLUDE_DIRECTORIES( BEFORE SYSTEM /opt/poky/1.3/sysroots/armv5te-poky-linux-gnueabi/usr/include )
LINK_DIRECTORIES( /opt/poky/1.3/sysroots/armv5te-poky-linux-gnueabi/usr/lib )
# where is the target environment
SET( CMAKE_FIND_ROOT_PATH /opt/poky/1.3/sysroots/armv5te-poky-linux-gnueabi/ )
#search for libraries and header files only in the target environment
SET( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
SET( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
# search for programs in the build host directories
SET( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
My CMake project is:
cmake_minimum_required( VERSION 2.8.9 )
project ( TEST )
set( BOOST_COMPONENTS thread )
find_package( Boost COMPONENTS ${BOOST_COMPONENTS} )
add_executable( test test.cpp )
target_link_libraries( test ${Boost_THREAD_LIBRARY} )
My cpp code used for tests:
#include <boost/thread/thread.hpp>
#include <iostream>
void hello()
{
std::cout << "Hello!" << std::endl;
}
int main()
{
boost::thread thrd( &hello );
thrd.join();
return 0;
}
Thank you by advance for your help
link_directories(${Boost_LIBRARY_DIR})
and removeset( Boost_REALPATH on )
? – Piotr Skotnicki/opt/poky/1.3/sysroots...
, how about${Boost_LIBRARY_DIR}
? – Piotr Skotnicki