Creating a AppImage for linux


if you wanna have a portable AppImage for your OF app under linux you can do this (im not sure if it will work with all linux vs but i’m under manjaro on a razer blade) just i case

Create an AppDir structure that looks (as a minimum) like this:

MyApp.AppDir/AppRun    --- you donwnload this from [here]( get the one AppRun-x86_64 and just renamed to AppRun
MyApp.AppDir/usr/bin/myapp --- copy your OF app here  i copied  the bin folder complete
MyApp.AppDir/usr/lib/ -- din't know what to do with this but i   copy   here also 

you have to make de MyApp.AppDir/myapp.desktop file like this

[Desktop Entry]

and then just download the appimagetool-x86_64.AppImage and run the appimage tool to your MyApp.AppDir and you will get a portable appImage under linux


I didn’t know what AppImage is. This is what I found:

AppImage is a format for distributing portable software on Linux without needing superuser permissions to install the application. It tries also to allow Linux distribution-agnostic binary software deployment for application developers, also called Upstream packaging. Released first in 2004 under the name klik, it was continuously developed, then renamed in 2011 to PortableLinuxApps and later in 2013 to AppImage.


Yup that it is


thanks @cyrstem for sharing

it’s a nice way to package all your app under the same icon and it has the benefit to reduce its size

1 Like

Yes i did that don’t know if its necessary ill test in a different system without of dependencies install and see if it works

1 Like

I am trying AppImage and it works fine: I am able to run my OF app on fresh Raspberry Pi install.

Only problem I am running into is that the files are write-protected so saving settings to xml files or anything in data folder do not work.
It also seems that I need to run the app with sudo otherwise some file access are denied.

But all in all, this is awesome! Thanks for this post :slight_smile:

1 Like

I made some more experiment to understand how to save data or settings in a nice way. AppImage has a way to deal with that, it is explained here.

I have my AppImage called " TestApp-armhf.AppImage" and I created 2 folders with the same name and .home and .config added to the name.

Then in my oF app I have the following code:

ofLogNotice() << "User Home dir: " << ofFilePath::getUserHomeDir();
ofLogNotice() << "Exe dir: " << ofFilePath::getCurrentExeDir();
ofLogNotice() << "Exe path: " << ofFilePath::getCurrentExePath();
ofLogNotice() << "Current working directory: " << ofFilePath::getCurrentWorkingDirectory();
ofLogNotice() << "";
ofLogNotice() << "$HOME dir: " << ofSystem("echo $HOME");
ofLogNotice() << "$CONFIG dir: " << ofSystem("echo $XDG_CONFIG_HOME");

And this gives the following output:

[notice ] User Home dir: /home/pi
[notice ] Exe dir: /tmp/.mount_TestApXKWxrk/usr/bin/
[notice ] Exe path: /tmp/.mount_TestApXKWxrk/usr/bin/testapp
[notice ] Current working directory: /tmp/.mount_TestApXKWxrk/usr
[notice ]
[notice ] $HOME dir: /home/pi/AppImage/TestApp-armhf.AppImage.home
[notice ] $CONFIG dir: /home/pi/AppImage/TestApp-armhf.AppImage.config

I still need to copy the settings file and what I want to save in the .config folder but that’s a easy way to have our app and data folder working from any location and get the path programmatically from OF.


so if i understand correctly you create two folders inside the .AppImage .config and .home and with that your able to load and save configuration files easily ?


You have to create those files next to the .AppImage, not inside.
Another way to do it is to add the 2 arguments ( --appimage-portable-home & --appimage-portable-config) when creating the AppImage. This will create empty folders for you automatically.

In my app I check the current working directory of my App and if the path starts with “/tmp/” I consider that it is in an AppImage.
Then I copy my settings file to the config folder and save/load my settings from there.


ok cool, so setting the destination folder on OF app should work and no more issues with sudo
thats great thanks!
one question did you try your app in raspbian? with out setting up OF first ?


Yes, I tried the app on fresh install of Raspbian buster. I only run apt-get update/upgrade and enabled the camera/i2c on the Pi as I use them in my app.

Though I had to copy really a lots of libraries in the AppImage/usr/lib folder. To get the list I used “ldd” command. Maybe some of those libs are not necessary but for now it’s good enough. Also I end up with an app which is more than 100MB.

1 Like