OpenFL 4.7 on a Raspberry Pi 2 or 3


So It’s a year since I had the time to play with OpenFL on a Raspberry Pi.
In this year The Raspberry Pi 3 came out and OpenFL went up a major version.
I was curious to see if this new version would still work on a Pi.

Well, it does and you need less tweaking.
Unfortunately the needed changes can’t be built automatically on the Travis built server
that is testing the Lime an OpenFL repositories. So you will (probably always) need to manually build lime.

So here’s the steps I went through, part of it is the same as the steps from my previous post.
you will still need to get neko2 and build haxe 3.2.1

If you just want to get it running you can try my setup script at this gist

I am assuming you are using the latest Raspbian Jessie. I’m using the 2017-01-11 version.

First of all I like to have all my stuff in a Development directory in the home directory so let’s create it along with some directories inside it.

this creates the following structure in /home/pi/:
— haxe
—- dev
—- lib
—- source

before we grab neko and haxe, let’s install some dependencies that you will need to compile them.

Now let’s grab neko, you can either build from source or use a binary from openfl.
If you would like to use the binary do the following

or you can build from source.
you can skip libraries when it asks you to, I’m not using the neko apache and gtk and mysql4 modules on the Pi

you can test if neko was installed by running

Now lets get the haxe-3.2.1 source
We will checkout out a specific branch

You should now have a working version of haxe and haxelib
so we’ll setup haxelib next
Earlier we made directories for haxelib libraries (/home/pi/Develeopment/haxe/lib) and libraries you build yourself or checkout from git (/home/pi/Develeopment/haxe/) this is how I do it but feel free to do otherwise

now to make things easer further along the road we will install and setup openfl eventhough it will not work right away
it will install some libraries we’ll need anyway. Maybe in the future this WILL be all you need to do.

(choose yes to install the openfl command)

gist for the steps so far is here:

you should now be able to run the openfl command and the lime command
but we’ll be checking out the source versions of both lime and openfl now in the dev directory

You can get OpenFL from git too, but for me it wasn’t nescesary



lime’s  commit:4dc184f337154219355d9ec5ed228e61aa826317 already has the changes I’m describing below.
And the raspberry pi target has been taken out of travis ci.
So from the next official lime version you will only have rebuild hxcpp and lime and won’t have to make manual changes


Because the Raspberry Pi has it’s OpenGLES2 libraries in a different place from other linux-distributions

adding paths to these libraries in the Build.xml file of lime/project and submitting to the repository will crash the buildserver that is based on linux but doesn’t have these paths. So we will have to do this manually for now.

edit the file lime/project/Build.xml, for instance with nano

now uncomment line 357 (approximately) so that it reads:

And add the following line after line 361 (approximately)

and add this section right after line 190 (approximately) : the closing section xml tag for the emscripten section

before we can rebuild lime we have to rebuild hxcpp normal and static

Note: the first line may give an error: g++: error: unrecognized command line option ‘-m32’
if it does just run the first line again.

Now let’s have haxelib use the GitHub version of lime

I have to force a setting in ~/.hxcpp_config.xml by adding the following line
right after   <section id=”vars”>

And I find I useful  to have the same  setting in ~/.lime/config.xml in the ‘defines’ section,
so thet you can have specific rpi conditionals in your project.xml

Before we’re ready to build Lime we need to make some changes to the SDL.config.h file.

We need to uncomment LINE 83:

so that it becomes:

change line 291 to

and comment out all lines that reference X11 defines (because X11 won’t work!)

[lines: 290,292,293, 306,308,311]

Now SDL should build with udev enabled (for input events)
and raspberry pi specific opengles display drivers.

So let’s build lime

You should now have a working lime for your Raspberry Pi

now it’s time to compile Pirate-pig
I’ll make a directory for openfl projects and create the PiratePig Example here.
Then we’ll make a small change to the PiratePig Example.
This is because the application is not show in a window and therefore you have no way to close the application.
We’ll just add a keydown EventListener on the stage, choose a key combo and issue the quit command

now add the eventlistener to the ‘public function new () ‘ function right after the onResize listener

add an import statement for the Keyboard constants (after line 8 i.e.)

and add the callback after the onResize Callback

now you will be able to quit the app with f4

Then there is just one thing left to do
time for another coffee and maybe eat something!

I think you should be looking at pirate-pigs, pandas and more!

game_panda game_piratePig