Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm gonna try to write this as a tutorial for you so it becomes easy to follow.</p> <h2>Pre-requirements</h2> <p>Before you start you need to make sure the following is installed:</p> <pre><code>apt-get install git rsync cmake ia32-libs </code></pre> <h2>Let's cross compile a Pie!</h2> <p>Start with making a folder in your home directory called <code>raspberrypi</code>.</p> <p>Go in to this folder and pull down the ENTIRE tools folder you mentioned above:</p> <pre><code>git clone git://github.com/raspberrypi/tools.git </code></pre> <p>You wanted to use the following of the 3 ones, <code>gcc-linaro-arm-linux-gnueabihf-raspbian</code>, if I did not read wrong.</p> <p>Go into your home directory and add:</p> <pre><code>export PATH=$PATH:$HOME/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin </code></pre> <p>to the end of the file named <code>~/.bashrc</code></p> <p>Now you can either log out and log back in (i.e. restart your terminal session), or run <code>. ~/.bashrc</code> in your terminal to pick up the <code>PATH</code> addition in your current terminal session.</p> <p>Now, verify that you can access the compiler <code>arm-linux-gnueabihf-gcc -v</code>. You should get something like this:</p> <pre><code>Using built-in specs. COLLECT_GCC=arm-linux-gnueabihf-gcc COLLECT_LTO_WRAPPER=/home/tudhalyas/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../libexec/gcc/arm-linux-gnueabihf/4.7.2/lto-wrapper Target: arm-linux-gnueabihf Configured with: /cbuild/slaves/oort61/crosstool-ng/builds/arm-linux-gnueabihf-raspbian-linux/.b uild/src/gcc-linaro-4.7-2012.08/configure --build=i686-build_pc-linux-gnu --host=i686-build_pc- linux-gnu --target=arm-linux-gnueabihf --prefix=/cbuild/slaves/oort61/crosstool-ng/builds/arm-l inux-gnueabihf-raspbian-linux/install --with-sysroot=/cbuild/slaves/oort61/crosstool-ng/builds/ arm-linux-gnueabihf-raspbian-linux/install/arm-linux-gnueabihf/libc --enable-languages=c,c++,fo rtran --disable-multilib --with-arch=armv6 --with-tune=arm1176jz-s --with-fpu=vfp --with-float= hard --with-pkgversion='crosstool-NG linaro-1.13.1+bzr2458 - Linaro GCC 2012.08' --with-bugurl= https://bugs.launchpad.net/gcc-linaro --enable-__cxa_atexit --enable-libmudflap --enable-libgom p --enable-libssp --with-gmp=/cbuild/slaves/oort61/crosstool-ng/builds/arm-linux-gnueabihf-rasp bian-linux/.build/arm-linux-gnueabihf/build/static --with-mpfr=/cbuild/slaves/oort61/crosstool- ng/builds/arm-linux-gnueabihf-raspbian-linux/.build/arm-linux-gnueabihf/build/static --with-mpc =/cbuild/slaves/oort61/crosstool-ng/builds/arm-linux-gnueabihf-raspbian-linux/.build/arm-linux- gnueabihf/build/static --with-ppl=/cbuild/slaves/oort61/crosstool-ng/builds/arm-linux-gnueabihf -raspbian-linux/.build/arm-linux-gnueabihf/build/static --with-cloog=/cbuild/slaves/oort61/cros stool-ng/builds/arm-linux-gnueabihf-raspbian-linux/.build/arm-linux-gnueabihf/build/static --wi th-libelf=/cbuild/slaves/oort61/crosstool-ng/builds/arm-linux-gnueabihf-raspbian-linux/.build/a rm-linux-gnueabihf/build/static --with-host-libstdcxx='-L/cbuild/slaves/oort61/crosstool-ng/bui lds/arm-linux-gnueabihf-raspbian-linux/.build/arm-linux-gnueabihf/build/static/lib -lpwl' --ena ble-threads=posix --disable-libstdcxx-pch --enable-linker-build-id --enable-plugin --enable-gol d --with-local-prefix=/cbuild/slaves/oort61/crosstool-ng/builds/arm-linux-gnueabihf-raspbian-li nux/install/arm-linux-gnueabihf/libc --enable-c99 --enable-long-long Thread model: posix gcc version 4.7.2 20120731 (prerelease) (crosstool-NG linaro-1.13.1+bzr2458 - Linaro GCC 2012.08 ) </code></pre> <h2>But hey! I did that and the libs still don't work!</h2> <p>We're not done yet! So far, we've only done the basics.</p> <p>In your <code>raspberrypi</code> folder, make a folder called <code>rootfs</code>.</p> <p>Now you need to copy the entire <code>/lib</code>and <code>/usr</code> directory to this newly created folder. I usually bring the rpi image up and copy it via rsync:</p> <pre><code>rsync -rl --delete-after --safe-links pi@192.168.1.PI:/{lib,usr} $HOME/raspberrypi/rootfs </code></pre> <p>where <code>192.168.1.PI</code> is replaced by the IP of your Raspberry Pi.</p> <p>Now, we need to write a <code>cmake</code> config file. Open <code>~/home/raspberrypi/pi.cmake</code> in your favorite editor and insert the following:</p> <pre><code>SET(CMAKE_SYSTEM_NAME Linux) SET(CMAKE_SYSTEM_VERSION 1) SET(CMAKE_C_COMPILER $ENV{HOME}/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc) SET(CMAKE_CXX_COMPILER $ENV{HOME}/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++) SET(CMAKE_FIND_ROOT_PATH $ENV{HOME}/raspberrypi/rootfs) SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) </code></pre> <p>Now you should be able to compile your <code>cmake</code> programs simply by adding this extra flag: <code>-D CMAKE_TOOLCHAIN_FILE=$HOME/raspberrypi/pi.cmake</code>. </p> <p>Using a <a href="https://github.com/jameskbride/cmake-hello-world">cmake hello world</a> example:</p> <pre><code>git clone https://github.com/jameskbride/cmake-hello-world.git cd cmake-hello-world mkdir build cd build cmake -D CMAKE_TOOLCHAIN_FILE=$HOME/raspberrypi/pi.cmake ../ make scp CMakeHelloWorld pi@192.168.1.PI:/home/pi/ ssh pi@192.168.1.PI ./CMakeHelloWorld </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload