Cross compilation - FrankBau/meta-marsboard-bsp GitHub Wiki

The goal is to enable C projects for host and target build. Although C projects come often with a Makefile, a simple make is not well suited for cross-compilation. There are more evolved technologies available which better care for platform independence, library dependencies and cross-compilation:

Using Autotools

The github repo https://github.com/FrankBau/hello-cross-compilation contains a C project and instructions which can be compiled and linked

  1. on the build host
  2. on the target
  3. cross-compiled on the build host for the target

Rolling a bitbake Recipe for autotools Projects

see https://wiki.yoctoproject.org/wiki/Building_your_own_recipes_from_first_principles#The_bbexample_recipe

Further Reading

Using CMake

A working example opencv-app is included in the meta-marsboard-bsp. This example is targeted to the image-multimedia-full-with-opencv image built with X11/gtk support.

It's a simple standard live view application consisting of 3 files:

  • LICENSE
  • CMakeLists.txt
  • src/opencv-app.cpp

For simplicity, these files are included in a sub-folder of the the recipe folder and referenced in the recipe.

To cross-compile the project on the build-host, open a bitbake shell and enter

bitbake opencv-app

this will eventually build a .rpm package opencv-app-1.0-r0.cortexa9hf_vfp_neon.rpm located in the deployment folder under build/tmp/deploy/rpm/cortexa9hf_vfp_neon.

[Copy](Exchanging files with MarS Board) this package to the target and install it on the target:

rpm -i opencv-app-1.0-r0.cortexa9hf_vfp_neon.rpm

You are now able to execute it on the MarS Board:

opencv-app

The build artefacts on the build host are located in build/tmp/work/cortexa9hf-vfp-neon-poky-linux-gnueabi/opencv-app/1.0-r0:

  • src contains copies of the above 3 project files
  • build contains the generated files (like the generated Makefile)
  • temp contains all log files (log.) from bitbake and all generated shell scripts (run.)
  • deploy-rpms contains the .rpm packages for deployment and so on.

Further Reading