Cross Compile From Mac using Debian VM

Normally I use DISTCC but it is not great when there are compile errors and the linking process is still done on the RPi

The benefits of the below workflow:

Compile using the RPi as your source disk (no copying back app binaries - single point of OF source)
No Homebrew/Macports/crosstool-ng or fighting with Yosemite
Conceptually should work cross-platform

Components:
VirtualBox with Debian VM and cross-compiler
RPi with OF installed/SMB configured with mount point as / and read/write access

Workflow:
Mount Pi and edit OF projects over SMB
SSH into Debian VM to compile
Separate SSH into RPi to run apps

3 Likes

I’m also considering switching my rpi-build-and-boot virtual machine over to SMB. NFS just isn’t getting any less broken over time!

Thanks for the guide @jvcleave! I have followed it almost completely (except that I am using a vagrant box version of Debian 7.3), but am running into an error when trying to compile.

vagrant@vagrant-debian-wheezy-i386:/media/Data/home/pi/openFrameworks/apps/myApps/emptyExample$ make -j6 RPI_TOOLS=$RPI_TOOLS RPI_ROOT=$RPI_ROOT GST_VERSION=1.0 PLATFORM_OS=Linux PLATFORM_ARCH=armv6l
cat: /opt/vc/include/interface/vmcs_host/vc_dispmanx.h: No such file or directory
armv6l
checking pkg-config libraries:   cairo zlib gstreamer-app-1.0 gstreamer-1.0 gstreamer-video-1.0 gstreamer-base-1.0 libudev freetype2 fontconfig sndfile openal openssl libpulse-simple alsa 
../../../libs/openFrameworksCompiled/project/makefileCommon/config.shared.mk:260: *** couldn't find some pkg-config packages, did you run the latest install_dependencies.sh?.  Stop.

I manually ran the /media/Data/home/pi/openFrameworks/scripts/linux/debian/install_dependencies.sh script, but that did not fix it. It probably has to do with the absolute paths that you mention in your Troubleshooting part, as find ~/RPI_ROOT/ -name libm.so returns /home/vagrant/RPI_ROOT/usr/lib/arm-linux-gnueabihf/libm.so. However, I’m unclear as to how to proceed. I checked the folder containing libm.so, and it’s packed. Should I remove everything here?

Thanks!

@eelke

I updated the gist - I was using my existing openFrameworks on the RPi

You will need to run install_dependencies.sh on the RPi - not the Debian VM (although it is probably ok if you did)

EDIT:
After running install_dependencies.sh you will want to run through these copy instructions again

The lines starting with $ mkdir RPI_ROOT to $ cp -Rv /media/Data/opt RPI_ROOT/

@jvcleave Thanks! Just to be sure, I had openFrameworks already working alright on the Pi, I could compile fine there. So should I now run the install_dependencies.sh from the oF/scripts/debian folder on the Pi? Or the debian_armv61 folder?

@eelke

Hmm - did you do the copy process (starts around line 77 on the gist) - this is your first error

cat: /opt/vc/include/interface/vmcs_host/vc_dispmanx.h: No such file or directory armv6l

This file shouldn’t be effected by the absolute paths (applies mostly to libs)

@jvcleave I did indeed. I just found out the file you mention is not located at the /opt folder, but at ~/RPI_ROOT/opt. Turned out something went wrong with the export commands. I fixed that, and now the first bug is gone, awesome. Now I only get the install_dependencies.sh warning. Do you know which version I should run? Cheers!

@eelke

What do you get if you run this command from the Debian VM?

echo $PKG_CONFIG_PATH

for instance mine says

$ echo $PKG_CONFIG_PATH
/home/jvcleave/RPI_ROOT/usr/lib/arm-linux-gnueabihf/pkgconfig:/home/jvcleave/RPI_ROOT/usr/share/pkgconfig:/home/jvcleave/RPI_ROOT/usr/lib/pkgconfig

It’s basically working like this

  1. You ran the install_dependencies.sh on the RPI previously if you were able to compile on the RPi
  2. That installed a bunch of packages (cairo zlib gstreamer-app-1.0 etc) into /usr/lib on the RPi
  3. You then copied those over in with these instructions
$ cp -Rv /media/Data/usr/include RPI_ROOT/usr/ 
$ cp -Rv /media/Data/usr/lib RPI_ROOT/usr/
$ cp -Rv /media/Data/usr/share RPI_ROOT/usr/

When make runs it then uses pkg-config to get the info for cairo zlib gstreamer-app-1.0 etc using the paths from the environment variable set in PKG_CONFIG_PATH

Maybe this - add

MAKEFILE_DEBUG=1

to the top of

/home/pi/openFrameworks/apps/myApps/emptyExample/Makefile

and then try to compile emptyExample

this is my output (I cleaned OF so it would be forced to compile as well)

@jvcleave Thank you, once again!
I have no idea what happened before, but it’s kind of now obvious that something went wrong while setting the environment variables, as the $ echo $PKG_CONFIG_PATH did not return anything. After that I checked the other variables and not a single one was set.
I thought I did set them all before, but obviously something went wrong there, because after setting them again and following the steps after, oF started compiling! (Currently still going on, but so far it seems to work now.) Will update this post after it’s done (or failed).

EDIT: Got really far, but not far enough. It’s stuck on the error below ( cannot find /lib/arm-linux-gnueabihf/libpthread.so.0 inside /home/vagrant/RPI_ROOT). This file does exist, but the path is incorrect. (File exists at /home/vagrant/RPI_ROOT/usr/lib/arm-linux-gnueabihf/)

long shot but try changing

-Wl,--as-needed
to
-Wl,--no-as-needed

here