Skip to content

Instantly share code, notes, and snippets.

@devsecfranklin
Last active February 24, 2018 22:07
Show Gist options
  • Save devsecfranklin/4475416417f87ebd7bc014990a9ffd68 to your computer and use it in GitHub Desktop.
Save devsecfranklin/4475416417f87ebd7bc014990a9ffd68 to your computer and use it in GitHub Desktop.
compile for raspberry pi with tool chain

sudo apt-get install git rsync cmake lib32z1 lib32ncurses5

git clone git://github.com/raspberrypi/tools.git sudo mv tools /opt/raspi-toolchain

  • add line to .bashrc export PATH=$PATH:/opt/raspi-toolchain/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin
arm-linux-gnueabihf-gcc -v
  • In your /opt/raspi-toolchain folder, make a folder called rootfs.
rsync -rl --delete-after --safe-links thedevilsvoice@batpack:/{lib,usr} /opt/raspi-toolchain/rootfs
  • Create /opt/raspi-toolchain/pi.cmake
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_VERSION 1)
SET(CMAKE_C_COMPILER /opt/raspi-toolchain/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc)
SET(CMAKE_CXX_COMPILER /opt/raspi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++)
#SET(CMAKE_FIND_ROOT_PATH $ENV{HOME}/raspberrypi/rootfs)
SET(CMAKEFIND_ROOT_PATH /opt/raspi-toolchain/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)
  • test it
git clone https://github.com/jameskbride/cmake-hello-world.git 
cd cmake-hello-world
mkdir build
cd build
cmake -D CMAKE_TOOLCHAIN_FILE=/opt/raspi-toolchain/pi.cmake ../
make
scp CMakeHelloWorld thedevilsvoice@batpack:/tmp/
ssh pi@batpack ./CMakeHelloWorld
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment