Last active
October 25, 2016 15:31
-
-
Save jvcleave/ed342fb2d41564bcdab6 to your computer and use it in GitHub Desktop.
Instructions for building a Jessie VM to cross-compile openFrameworks 0.9 applications for the Raspberry Pi 1 (arm6)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ON THE RPI (if you haven't downloaded openFrameworks) | |
cd | |
curl -O http://192.237.185.151/versions/nightly/of_v20151008_linuxarmv6l_nightly.tar.gz | |
mkdir openFrameworks | |
tar vxfz of_v20151008_linuxarmv6l_nightly.tar.gz -C openFrameworks --strip-components 1 | |
cd /home/pi/openFrameworks/scripts/linux/debian | |
sudo ./install_dependencies.sh | |
#INSTALL SMB WITH / ACCESS | |
# https://gist.github.com/jvcleave/f41132324ca75c2268f9 | |
#ON THE MAC: | |
#INSTALL VIRTUALBOX | |
#INSTALL DEBIAN 64BIT JESSIE | |
#http://gemmei.acc.umu.se/mirror/cdimage/release/8.2.0-live/amd64/iso-hybrid/debian-live-8.2.0-amd64-standard.iso | |
#Use Bridge Mode (allows access to local network without NAT) | |
#No Desktop Needed | |
#Give it at least 10GB storage | |
#ON THE DEBIAN VM: | |
#NOTE:BELOW INSTRUCTIONS USE pi AS DEBIAN USER | |
#ADD pi USER TO ROOT GROUP | |
#(via https://www.privateinternetaccess.com/forum/discussion/18063/debian-8-1-0-jessie-sudo-fix-not-installed-by-default) | |
su | |
apt-get install sudo | |
adduser pi sudo | |
nano /etc/sudoers | |
# under "User privilege specification" add pi line below to look like | |
# User privilege specification | |
root ALL=(ALL:ALL) ALL | |
pi ALL=(ALL:ALL) ALL | |
#INSTALL NEEDED PACKAGES | |
sudo apt-get install pkg-config make build-essential cifs-utils avahi-daemon avahi-utils libavahi-compat-libdnssd-dev | |
# MOUNT PI ON DEBIAN | |
sudo mkdir /media/Data | |
sudo nano /etc/fstab | |
#ADD LINE (raspberrypi.local is RPi Network address - can be IP) | |
//raspberrypi.local/Data /media/Data cifs credentials=/home/pi/.smbcredentials,iocharset=utf8 0 0 | |
#save and exit nano | |
#CREATE FILE TO STORE SMB USER/PASS | |
nano /home/pi/.smbcredentials | |
#add RPi samba user/pass (don't add this line) | |
username=pi | |
password=raspberry | |
#save and exit nano | |
#MOUNT PI | |
sudo mount -a | |
#TEST | |
ls -al /media/Data | |
#SET ENVIRONMENT VARIABLES | |
cd | |
nano .profile | |
#add lines | |
export GST_VERSION=1.0 | |
export RPI_ROOT=/home/pi/RPI_ROOT | |
export RPI_TOOLS=/opt/cross/bin | |
export TOOLCHAIN_ROOT=/opt/cross/bin | |
export PLATFORM_OS=Linux | |
export PLATFORM_ARCH=armv6l | |
export PKG_CONFIG_PATH=$RPI_ROOT/usr/lib/arm-linux-gnueabihf/pkgconfig:$RPI_ROOT/usr/share/pkgconfig:$RPI_ROOT/usr/lib/pkgconfig | |
#save and exit nano | |
#Apply variables | |
source .profile | |
#COPY NECESSARY RPI CONTENTS FOR COMPILER | |
cd | |
mkdir RPI_ROOT | |
cd RPI_ROOT | |
ln -s /media/Data/etc/ etc | |
ln -s /media/Data/lib/ lib | |
ln -s /media/Data/opt/ opt | |
cp -Rv /media/Data/usr/ usr | |
#FIX HARDCORDED LINKS TO /lib | |
#TODO Script this: (old fixQualifiedPaths script doesn't work) | |
cd usr/lib/arm-linux-gnueabihf | |
rm libudev.so libanl.so libBrokenLocale.so libcidn.so libcrypt.so libdbus-1.so libdl.so libexpat.so libglib-2.0.so liblzma.so libm.so libnsl.so libnss_compat.so libnss_dns.so libnss_files.so libnss_hesiod.so libnss_nisplus.so libnss_nis.so libpcre.so libpng12.so.0 libresolv.so libthread_db.so libusb-0.1.so.4 libusb-1.0.so libutil.so libz.so | |
ln -s ../../../lib/arm-linux-gnueabihf/libanl.so.1 libanl.so | |
ln -s ../../../lib/arm-linux-gnueabihf/libBrokenLocale.so.1 libBrokenLocale.so | |
ln -s ../../../lib/arm-linux-gnueabihf/libcidn.so.1 libcidn.so | |
ln -s ../../../lib/arm-linux-gnueabihf/libcrypt.so.1 libcrypt.so | |
ln -s ../../../lib/arm-linux-gnueabihf/libdbus-1.so.3.8.13 libdbus-1.so | |
ln -s ../../../lib/arm-linux-gnueabihf/libdl.so.2 libdl.so | |
ln -s ../../../lib/arm-linux-gnueabihf/libexpat.so.1.6.0 libexpat.so | |
ln -s ../../../lib/arm-linux-gnueabihf/libglib-2.0.so.0 libglib-2.0.so | |
ln -s ../../../lib/arm-linux-gnueabihf/liblzma.so.5.0.0 liblzma.so | |
ln -s ../../../lib/arm-linux-gnueabihf/libm.so.6 libm.so | |
ln -s ../../../lib/arm-linux-gnueabihf/libnsl.so.1 libnsl.so | |
ln -s ../../../lib/arm-linux-gnueabihf/libnss_compat.so.2 libnss_compat.so | |
ln -s ../../../lib/arm-linux-gnueabihf/libnss_dns.so.2 libnss_dns.so | |
ln -s ../../../lib/arm-linux-gnueabihf/libnss_files.so.2 libnss_files.so | |
ln -s ../../../lib/arm-linux-gnueabihf/libnss_hesiod.so.2 libnss_hesiod.so | |
ln -s ../../../lib/arm-linux-gnueabihf/libnss_nisplus.so.2 libnss_nisplus.so | |
ln -s ../../../lib/arm-linux-gnueabihf/libnss_nis.so.2 libnss_nis.so | |
ln -s ../../../lib/arm-linux-gnueabihf/libpcre.so.3 libpcre.so | |
ln -s ../../../lib/arm-linux-gnueabihf/libpng12.so.0 libpng12.so.0 | |
ln -s ../../../lib/arm-linux-gnueabihf/libresolv.so.2 libresolv.so | |
ln -s ../../../lib/arm-linux-gnueabihf/libthread_db.so.1 libthread_db.so | |
ln -s ../../../lib/arm-linux-gnueabihf/libusb-0.1.so.4 libusb-0.1.so.4 | |
ln -s ../../../lib/arm-linux-gnueabihf/libusb-1.0.so.0.1.0 libusb-1.0.so | |
ln -s ../../../lib/arm-linux-gnueabihf/libutil.so.1 libutil.so | |
ln -s ../../../lib/arm-linux-gnueabihf/libz.so.1.2.8 libz.so | |
ln -s ../../../lib/arm-linux-gnueabihf/libudev.so.1.5.0 libudev.so | |
cd | |
#CREATE CROSS COMPILER | |
mkdir CROSS_BUILD_TOOLS | |
cd CROSS_BUILD_TOOLS | |
wget https://gist.githubusercontent.com/jvcleave/ed342fb2d41564bcdab6/raw/495e723cc8e5c64051f3f16697515c5d0eb95f8c/build_cross_gcc.sh | |
sudo chmod +x build_cross_gcc.sh | |
sudo ./build_cross_gcc.sh | |
#TRY AND COMPILE | |
make -C /media/Data/home/pi/openFrameworks/examples/empty/emptyExample/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
set -e | |
trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG | |
trap 'echo FAILED COMMAND: $previous_command' EXIT | |
#------------------------------------------------------------------------------------------- | |
# This script will download packages for, configure, build and install a GCC cross-compiler. | |
# Customize the variables (INSTALL_PATH, TARGET, etc.) to your liking before running. | |
# If you get an error and need to resume the script from some point in the middle, | |
# just delete/comment the preceding lines before running it again. | |
# | |
# See: http://preshing.com/20141119/how-to-build-a-gcc-cross-compiler | |
#------------------------------------------------------------------------------------------- | |
export SYSROOT=/home/pi/RPI_ROOT | |
INSTALL_PATH=/opt/cross | |
TARGET=arm-linux-gnueabihf | |
LINUX_ARCH=arm | |
CONFIGURATION_OPTIONS="--disable-werror" | |
SYSROOT_OPTIONS="--with-sysroot=$SYSROOT --with-build-sysroot=$SYSROOT" | |
USE_NEWLIB=0 | |
PARALLEL_MAKE=-j4 | |
BINUTILS_VERSION=binutils-2.25.1 | |
GCC_VERSION=gcc-4.9.2 | |
LINUX_KERNEL_VERSION=linux-4.1.7 | |
GLIBC_VERSION=glibc-2.20 | |
MPFR_VERSION=mpfr-3.1.2 | |
GMP_VERSION=gmp-6.0.0a | |
MPC_VERSION=mpc-1.0.2 | |
ISL_VERSION=isl-0.12.2 | |
CLOOG_VERSION=cloog-0.18.1 | |
export PATH=$INSTALL_PATH/bin:$PATH | |
# Download packages | |
export http_proxy=$HTTP_PROXY https_proxy=$HTTP_PROXY ftp_proxy=$HTTP_PROXY | |
wget -nc https://ftp.gnu.org/gnu/binutils/$BINUTILS_VERSION.tar.gz | |
wget -nc https://ftp.gnu.org/gnu/gcc/$GCC_VERSION/$GCC_VERSION.tar.gz | |
wget -nc https://www.kernel.org/pub/linux/kernel/v4.x/$LINUX_KERNEL_VERSION.tar.xz | |
wget -nc https://ftp.gnu.org/gnu/glibc/$GLIBC_VERSION.tar.xz | |
wget -nc https://ftp.gnu.org/gnu/mpfr/$MPFR_VERSION.tar.xz | |
wget -nc https://ftp.gnu.org/gnu/gmp/$GMP_VERSION.tar.xz | |
wget -nc https://ftp.gnu.org/gnu/mpc/$MPC_VERSION.tar.gz | |
wget -nc ftp://gcc.gnu.org/pub/gcc/infrastructure/$ISL_VERSION.tar.bz2 | |
wget -nc ftp://gcc.gnu.org/pub/gcc/infrastructure/$CLOOG_VERSION.tar.gz | |
# Extract everything | |
for f in *.tar*; do tar xfkv $f; done | |
# Make symbolic links | |
cd $GCC_VERSION | |
ln -sf `ls -1d ../mpfr-*/` mpfr | |
ln -sf `ls -1d ../gmp-*/` gmp | |
ln -sf `ls -1d ../mpc-*/` mpc | |
ln -sf `ls -1d ../isl-*/` isl | |
ln -sf `ls -1d ../cloog-*/` cloog | |
cd .. | |
# Step 1. Binutils | |
mkdir -p build-binutils | |
cd build-binutils | |
../$BINUTILS_VERSION/configure --prefix=$INSTALL_PATH --target=$TARGET $CONFIGURATION_OPTIONS $SYSROOT_OPTIONS | |
make $PARALLEL_MAKE | |
make install | |
cd .. | |
# Step 2. Linux Kernel Headers | |
if [ $USE_NEWLIB -eq 0 ]; then | |
cd $LINUX_KERNEL_VERSION | |
make ARCH=$LINUX_ARCH INSTALL_HDR_PATH=$INSTALL_PATH/$TARGET headers_install | |
cd .. | |
fi | |
# Step 3. C/C++ Compilers | |
mkdir -p build-gcc | |
cd build-gcc | |
if [ $USE_NEWLIB -ne 0 ]; then | |
NEWLIB_OPTION=--with-newlib | |
fi | |
../$GCC_VERSION/configure --prefix=$INSTALL_PATH --target=$TARGET --enable-languages=c,c++ --with-float=hard $CONFIGURATION_OPTIONS $SYSROOT_OPTIONS | |
make $PARALLEL_MAKE all-gcc | |
make install-gcc | |
cd .. | |
if [ $USE_NEWLIB -ne 0 ]; then | |
# Steps 4-6: Newlib | |
mkdir -p build-newlib | |
cd build-newlib | |
../newlib-master/configure --prefix=$INSTALL_PATH --target=$TARGET $CONFIGURATION_OPTIONS | |
make $PARALLEL_MAKE | |
make install | |
cd .. | |
else | |
# Step 4. Standard C Library Headers and Startup Files | |
mkdir -p build-glibc | |
cd build-glibc | |
../$GLIBC_VERSION/configure --prefix=$INSTALL_PATH/$TARGET --build=$MACHTYPE --host=$TARGET --target=$TARGET --with-headers=$INSTALL_PATH/$TARGET/include $CONFIGURATION_OPTIONS libc_cv_forced_unwind=yes | |
make install-bootstrap-headers=yes install-headers | |
make $PARALLEL_MAKE csu/subdir_lib | |
install csu/crt1.o csu/crti.o csu/crtn.o $INSTALL_PATH/$TARGET/lib | |
$TARGET-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o $INSTALL_PATH/$TARGET/lib/libc.so | |
touch $INSTALL_PATH/$TARGET/include/gnu/stubs.h | |
cd .. | |
# Step 5. Compiler Support Library | |
cd build-gcc | |
make $PARALLEL_MAKE all-target-libgcc | |
make install-target-libgcc | |
cd .. | |
# Step 6. Standard C Library & the rest of Glibc | |
cd build-glibc | |
make $PARALLEL_MAKE | |
make install | |
cd .. | |
fi | |
# Step 7. Standard C++ Library & the rest of GCC | |
cd build-gcc | |
make $PARALLEL_MAKE all | |
make install | |
cd .. | |
trap - EXIT | |
echo 'Success!' | |
I am having the same issue as @Meach Meach, did you resolve the libc issue? It looks like the cross folder does not exist in /opt/ ...
looking at the config log these two lines seem to be the problem:
arm-linux-gnueabihf-gcc: error: unrecognized command line option '-qversion'
arm-linux-gnueabihf-gcc: fatal error: no input files
Update: the build_cross_gcc.sh file linked via wget doesn't have the NEWLIB=0 line included. Adding that fixed issue.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi there,
for some reasons when I run
sudo ./build_cross_gcc.sh
it fails with the error:I definitely made sure that I go thru all steps without mistake (did the process 3 times). Im not even sure what that error means and therefore where to look to fix it :/
If anyone can help me that would be really appreciated :)
I got a Raspberry Pi2 Model B , using debian-live-8.5.0-amd64-standard.iso in VirtualBox and 2016-05-27-raspbian-jessie.img is installed on my Pi.