AppImage

Apps for AppImage - any recommendations for programmers?

#1

Hi
I strugle with AppImage and I have some success (AppImage is created and my app can run from it).
But I have strange problem: When I start my app (writen with C++ and Qt) I setup all dirs suposed to use by my app (this is due to operating systems differences). Especially I have dir to images. I setup these dirs simply related to my exe (argv[0] main function parameter). Problem is that I have message like this:


Error: Exception occurs!
File: /home/szyk/!-EnergoKod/!-Libs/EnergoKodEditor1/Src/LineNumberArea.cpp, in line: 68, in function: loadSettings
Error code: 6, Error message: Bookmark image not found! Missing file: /home/szyk/!-EnergoKod/Textprofan2/Installers/Linux/share/Textprofan2-x86_64.AppImage/Images/bookmark.svg
Module: Energo Kod Editor 1 library
Code: 6

In this case I suppose (on Linux) my exe is located in /usr/bin and images are in /usr/share/Textprofan2/Images
I want to write my app properly so I want to know how should I setup my internaly used dirs.

So my question is:
How shoud I access my app resources? In case it is working inside AppImage package. It require some special hanling? Or I lame in my code?

Best regards
Szyk Cech

#2

Hi and welcome.

You could use QCoreApplication::applicationDirPath()
and construct a relative path to your resources from there.

http://doc.qt.io/qt-5/qcoreapplication.html#applicationDirPath

1 Like
#3

Thank you! You are avesome expert!!!

#4

Your solution cover cases:

  1. when I run my app from AppImage package
  2. when I run my app from sources (from /usr/local/bin dir)
  3. when user use custom command e.g.: cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release

But it does not cover one importand case:
4) compile from Ide in debug mode and run without install. In this case relay on exe position is useless.

Do you have any advices how to manage 4. case?

I can see two solutions:
I. Add function which search some default directories (e.g.: /usr/share , /usr/local/share , ../share )
II. Create ../share/MyApp dir above build dir

But I don’t know what is “recomended” way…