Xcode, OSX and Raspberry Pi

Hi everyone,

Could we cross compiling from OSX (on Xcode) for Raspberry Pi ?

I seen that : http://openframeworks.cc/setup/raspberrypi/Raspberry-Pi-Cross-compiling-guide.html
But i don’t understand the part with VM and Parallel machine. Meanwhile I already have a Parallel installation on my mac !

Yes you can. But only from Linux. So you will have to install Linux within parallels or Virtualbox (which I know has great support for linux)

I would download ubuntu it is the easiest to start with. http://www.ubuntu.com/download/desktop

If you want to use Xcode to edit this is what I use for most of my OF/RPi projects. It doesn’t help with compiling ( I use the Terminal/SSH for that) but it does allow auto-completion

3 Likes

Are you really sure it’s not possible to compile OF for Raspberry on OSX with Xcode? And if so why?

I am actually successfully cross-compiling c++ projects for raspberry pi on OSX, but I can’t get it to work with OF yet…

Compiling works, but I’m having a lot of linker issues like: libdl.a(dlsym.o): In function `dlsym': (.text+0xc): undefined reference to `__dlsym'

I’d really love to completely stop compiling on raspberry at all. It’s sooo sloooow :slight_smile:

I started by following this: http://www.jaredwolff.com/blog/cross-compiling-on-mac-osx-for-raspberry-pi/

https://github.com/twobitcircus/rpi-build-and-boot I have been enjoying that setup for cross compiling.

if you are using the makefiles, calling:

make RPI_TOOLS=path_to_compiler RPI_ROOT=path_to_RPI_system PLATFORM_OS=Linux  GST_VERSION=1.0 PLATFORM_ARCH=armv6l

should add the correct flags that avoid the linking issues

That’s very interesting Arturo, I’ll give that a try. I was creating my makefile from scratch because the ones with the Raspberry version of OF became so complex.
I have been using the original make files as a guide though.

My approach is: first compiling on Raspberry pi and copying all the compiled libraries to my mac and using those in my home made makefile. I don’t really know for sure if that’s actually a good approach… what do you think?

the OF makefiles are prepared to detect that you are crosscompiling and will add the correct flags, i’ve only used it under linux but i guess if you have the correct toolchain it should work the same under osx

I’ve tried your suggestion, ( with the toolchain I got from http://www.jaredwolff.com/blog/cross-compiling-on-mac-osx-for-raspberry-pi/ ) but I’m stuck at

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 
/bin/sh: pkg-config: command not found

I’m not familiar with pkg-config. Is it possible to compile / link without it?

mmh, yeah you should run:

pkg-config 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 --cflags

and

pkg-config 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

to get the compile flags and libraries you need to use, and change every PKG_CONFIG_LIBRARY in the makefiles with the result of those 2 calls.

or you can install pkg-config on osx, i think it should be available through brew or similar

Ah Yes, I’ll see if I can get pkg-config to work with homebrew!

Meanwhile I’ve continued working on my own simple makefile and I’ve run into this interesting warning:

/Volumes/xtools4/arm-none-linux-gnueabi/usr/include/features.h:326:0: warning: "__STDC_ISO_10646__" redefined [enabled by default]
 #define __STDC_ISO_10646__  200009L
 ^
In file included from <command-line>:0:0:
/Volumes/xtools4/arm-none-linux-gnueabi/arm-none-linux-gnueabi/sysroot/usr/include/stdc-predef.h:34:0: note: this is the location of the previous definition
 #define __STDC_ISO_10646__  201103L

and also this error:

/Volumes/xtools4/arm-none-linux-gnueabi/usr/lib/arm-linux-gnueabihf/libdl.a(dlsym.o): In function `dlsym':
(.text+0xc): undefined reference to `__dlsym'
1 Like

I’ve installed pkg-config with brew, and when I call pkg-config from the terminal it shows that it exists and is found, but when I run the OF makefile, it still says

/bin/sh: pkg-config: command not found

This is the full fun report:

=================== config.mk platform detection ================


PLATFORM_ARCH=armv6l


PLATFORM_OS=Linux


PLATFORM_VARIANT=default


PLATFORM_LIB_SUBPATH=linuxarmv6l


=================== config.mk paths =============================


OF_ADDONS_PATH=../../../addons


OF_EXPORT_PATH=../../../export


OF_EXAMPLES_PATH=../../../examples


OF_APPS_PATH=../../../apps


OF_LIBS_PATH=../../../libs


OF_LIBS_OPENFRAMEWORKS_PATH=../../../libs/openFrameworks


OF_LIBS_OF_COMPILED_PATH=../../../libs/openFrameworksCompiled


OF_LIBS_OF_COMPILED_PROJECT_PATH=../../../libs/openFrameworksCompiled/project


OF_SHARED_MAKEFILES_PATH=../../../libs/openFrameworksCompiled/project/makefileCommon


OF_PLATFORM_MAKEFILES=../../../libs/openFrameworksCompiled/project/linuxarmv6l


OF_CORE_LIB_PATH=../../../libs/openFrameworksCompiled/lib/linuxarmv6l


/bin/sh: pkg-config: command not found


/bin/sh: pkg-config: command not found


/bin/sh: pkg-config: command not found
/bin/sh: pkg-config: command not found
/bin/sh: pkg-config: command not found
/bin/sh: pkg-config: command not found
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 

/bin/sh: pkg-config: command not found

/Volumes/Archief/Library_Tim/Projecten/2014/24 RPI cross compile/_OF/of_v0.8.3_linuxarmv6/libs/openFrameworksCompiled/project/makefileCommon/config.shared.mk:260: *** couldn't find some pkg-config packages, did you run the latest install_dependencies.sh?.  Stop.

have you tried to restart the computer, i think homebrew sometimes adds a path the first time it installs something it might be that the path is set in the console but not yet in the session

I’ve tried it again after rebooting but, no luck. I still have the same exact errors.

I’ve managed to get an OF project to compile for raspberry pi on OSX with my very own makefile!
There were some symlinks broken and some absolute paths inside a few .so files that needed to become relative.

Still didn’t get it to work with the standard OF makefiles though…

I’m documenting my progress on cross compiling right here:

2 Likes