3

I'd like to cross compile from my AMD64 desktop to ARM7 for Beagleboard Black. So I started with this to get the cross compilers installed:

sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf

I also created a cmake toolchain file:

set (CMAKE_SYSTEM_NAME Linux)
set (CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
set (CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++)

When I run cmake, I see it does find the right compiler. But how do I deal with libraries that I need to link in? For example, boost? I assume I need the arm versions of those libraries on my x86/amd64 desktop for the compile and link to work.

Here is an example of the error messages I see when I try to run cmake:

cmake -DCMAKE_TOOLCHAIN_FILE=Arm_Toolchain ..
CMake Error at /usr/share/cmake-3.0/Modules/FindBoost.cmake:1199 (message):
  Unable to find the requested Boost libraries.
  Boost version: 1.55.0
  Boost include path: /usr/include
  Could not find the following static Boost libraries:
          boost_log_setup
          boost_log
          boost_date_time
          boost_filesystem
          boost_program_options
          boost_regex
          boost_system
          boost_thread
          boost_chrono
Stéphane
  • 19,459
  • 24
  • 95
  • 136

1 Answers1

2

Yes, you need the boost libraries which are not header only built for ARM. This SO question covers that: cross compile Boost 1.57.0 on ubuntu for arm

To make things like find_package work for cross compilation you should set CMAKE_FIND_ROOT_PATH.

Suppose you set CMAKE_FIND_ROOT_PATH to /opt/beagleboard. CMake will then look for the libraries at /opt/beagleboard/lib and /opt/beagleboard/usr/lib first, so install you libraries there and it should work.

A good explanation of the various CMake settings related to cross compilation can be found at http://www.vtk.org/Wiki/CMake_Cross_Compiling.

Community
  • 1
  • 1
m.s.
  • 16,063
  • 7
  • 53
  • 88