In updating the Raspberry Pi Cross-compiling guide for OF 0.9.0 I felt the forum may be a better place for this as these things can often change/require feedback. I am also using my personal workflow which everyone may not subscribe to.
The warning is - don't take this as an official guide but more "this is what I did and what works for me". I am also writing this post-process so there is a chance I am missing a step or instruction. Hopefully by this being a forum post it will be easier to get feedback or have others contribute solutions for different platforms.
System setup:
Mac OS X 10.10
Virtual Box 4.3 running 64 bit Debian Jessie (the cross-compiler VM)
Raspberry PI 1 with Debian Jessie
openFrameworks 0.9.0 for arm6
This process is also available for the RPI2/Arm7 with a few modifications but will address that later as compiling natively on the RPI2 isn't that bad.
Workflow overview/goal:
The end goal is to be able to create and edit openFrameworks apps on a Mac, compile quickly and run them on the RPI. This workflow does not have a copy task (e.g. compile on one machine and copy the app over). Compiling is done over the network.
In order to do this a few things must be configured.
Raspberry Pi has root filesystem (/) available as a mount point
The Mac and Cross-complier VM mounts the RPI as a network drive and is able to add, edit and change files without permission hassle.
Also in this workflow, the RPI has openFrameworks installed and is available to compile natively in case cross-compiler is not available
RPI Configuration:
Download and install openFrameworks 0.9.0 into /home/pi/openFrameworks according to the Getting Started guide
http://openframeworks.cc/setup/raspberrypi/Raspberry-Pi-Getting-Started.html
Install Samba server and configure it with root access
http://openframeworks.cc/setup/raspberrypi/Raspberry-Pi-SMB.html
Install Avahi in order to be able to access the RPI with an address like raspberrypi.local
sudo apt-get install cifs-utils avahi-daemon avahi-utils libavahi-compat-libdnssd-dev
Mac Configuration:
Install VirtualBox
https://www.virtualbox.org/wiki/Downloads
Install Debian 64 bit Jessie as a VM
This is the image I used
http://gemmei.acc.umu.se/mirror/cdimage/release/8.2.0-live/amd64/iso-hybrid/debian-live-8.2.0-amd64-standard.iso
For the VM Jessie installation you don't need a Desktop.
You will want to give it at least 10GB of disk storage
Use Bridge Mode for the Network adapter. This will allow access to local network without NAT entries.
I configured it with 4 processors and 2GB of RAM but less is probably ok for a laptop (my primary machine is a Mac Pro)
I made the primary user named "pi"
Here is what mine looks like in the end
VM Configuration:
From the Mac, ssh into the VM for the following steps. You can type them into the VM window but SSHing in allows easier copy/pasting with the Mac Terminal.
Add the user "pi" to the root group makes things simpler to install and configure the VM.
su
apt-get install sudo
adduser pi sudo
nano /etc/sudoers
Under "User privilege specification" add pi line below to look like
root ALL=(ALL:ALL) ALL
pi ALL=(ALL:ALL) ALL
Save and exit nano (Ctrl+O, Ctrl+X)
Hit Ctrl+D to go back to not being root
Install these packages to allow compiling, mounting network drives, and easier network access
sudo apt-get install pkg-config make build-essential cifs-utils avahi-daemon avahi-utils libavahi-compat-libdnssd-dev
Mount the RPI onto the Debian VM
sudo mkdir /media/Data
sudo nano /etc/fstab
Add the below line. raspberrypi.local is the RPI Network address and can be IP.
//raspberrypi.local/Data /media/Data cifs credentials=/home/pi/.smbcredentials,iocharset=utf8 0 0
Save and exit nano (Ctrl+O, Ctrl+X)
Create a file that will be used to store the RPI user/pass to mount the drive
nano /home/pi/.smbcredentials
Add lines
username=pi
password=raspberry
Save and exit nano (Ctrl+O, Ctrl+X)
Mount the RPI on the VM and test by listing the RPI root filesystem
sudo mount -a
ls -al /media/Data
So if you have successfully listed the files we can move onto the next step of creating local RPI filesystem that the VM will use to compile.
Create a folder named RPI_ROOT, go into it and just make symbolic links for some of the content we don't need to change and copy the folder we do.
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
Now we are at which has been the most problematic part. The files you just copied (and that the cross-complier will reference) have hardcoded symbolic links to "/lib". These need to be changed to a relative path in order to compile correctly. Previously there was a script named fixQualifiedPaths.sh that did this for you but wasn't working for me anymore (I suspect sed/regex changes).
The next commands do this but have an inherit problem of not being future-proof as they are targeting explicit version numbers that are likely to change with Raspbian updates.
These worked for me - since it is a local copy the worst that can happen is that you need to re-copy the RPI /usr
folder and do it manually
Go into the directory with the bad links (you still should be in RPI_ROOT)
cd usr/lib/arm-linux-gnueabihf
Remove the bad links
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
Recreate the symbolic links with relative paths
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
Build the Cross Compiler
We are now ready to build a cross-compiler. As mentioned in the cross-compiling guide, the previous tools provided by the RPI foundation are built on GCC 4.8 which doesn't provide the C++11 support OF 0.9.0 requires.
Make a temp folder for the cross-compiler build and download the build script
cd
mkdir CROSS_BUILD_TOOLS
cd CROSS_BUILD_TOOLS
wget https://gist.githubusercontent.com/jvcleave/ed342fb2d41564bcdab6/raw/495e723cc8e5c64051f3f16697515c5d0eb95f8c/build_cross_gcc.sh
Set the build script to executable
sudo chmod +x build_cross_gcc.sh
The script will take some time as it downloads, builds a GCC 4.9 based arm6 compiler, and installs it into /opt/cross/bin.
sudo ./build_cross_gcc.sh
Set Environmental Variables
If all goes well we are almost ready to cross-compile. Here we set some of the helper variables that the OF Makefile system will use for cross-compiling.
cd
nano .profile
Add the lines to the bottom
export GST_VERSION=1.0
export RPI_ROOT=/home/pi/RPI_ROOT
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 (Ctrl+O, Ctrl+X)
Apply the variables to your current session (they will be permanent from here on out)
source .profile
Try and compile:
make -C /media/Data/home/pi/openFrameworks/examples/empty/emptyExample/
If it compiles successfully, SSH into the RPI and run the application.
Some other stuff I do:
An additional line you can add to ~/.profile
to use multiple processors (4 being the amount of cores you want to dedicate)
export MAKEFLAGS="-j 4"
Make a link to the RPI openFrameworks folder on the VM so I don't have to type /media/Data/openFrameworks
cd
ln -s /media/Data/openFrameworks
Quirks:
Sometimes when I boot the VM it doesn't mount the RPI right away. This often solves it
sudo mount -a
Good luck!