Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QtApp: Linux compile howto #17

Closed
revast opened this issue Sep 25, 2017 · 61 comments
Closed

QtApp: Linux compile howto #17

revast opened this issue Sep 25, 2017 · 61 comments

Comments

@revast
Copy link

revast commented Sep 25, 2017

sudo apt-get install libpng16-dev qtmultimedia5-dev qt5-qmake qtbase5-dev

ubuntu 16.04 with kubuntu packports ppa activated, so qt 5.6.1

I had to change line 22 of MainWindow.cpp to
#include <**libpng16/**png.h>

and line 55 of MLVApp.pro to
linux-g++*: LIBS += -L/usr/local/lib/ -lz -lpng16

then the ususal
qmake-qt5 MLVApp.pro
make

@masc4ii
Copy link
Collaborator

masc4ii commented Sep 25, 2017

This maybe different from Linux to Linux. We already had Linux systems where it compiled 1:1 as it is.

Anyway - a howto is missing for all platforms.

@masc4ii
Copy link
Collaborator

masc4ii commented Sep 25, 2017

To not change MainWindow.cpp (OSX and Win port would be broken) you also could change line 56 in the .pro to:
linux-g++*: INCLUDEPATH += /usr/local/include/libpng16/

@masc4ii masc4ii changed the title Linux compile howto QtApp: Linux compile howto Sep 25, 2017
@revast
Copy link
Author

revast commented Sep 26, 2017

Would be nice if it would work out of the box for all distros.

I have now made an appimage. Turned out to be quite easy, thanks to linuxdeployqt

./linuxdeployqt m/MLVApp -appimage -bundle-non-qt-libs -verbose=2

where in folder m is the MLVApp executeable, a MLVApp.desktop file with Exec=MLVApp line in it, and MLVApp.png as well as a static FFMpeg executeable

@masc4ii
Copy link
Collaborator

masc4ii commented Sep 26, 2017

I added some lines to switch between ubuntu and opensuse in this commit.

@probonopd
Copy link

probonopd commented Oct 3, 2017

The desktop file is lacking a Categories= entry in the *.desktop file.

According to the menu spec,

By including one of the Main Categories in an application's desktop entry file, the application will be ensured that it will show up in a section of the application menu dedicated to this category. If multiple Main Categories are included in a single desktop entry file, the entry may appear more than once in the menu.

Hence, please add at least one of the following in the Categories= key.

Main Category Description Notes
AudioVideo Application for presenting, creating, or processing multimedia (audio/video)
Audio An audio application Desktop entry must include AudioVideo as well
Video A video application Desktop entry must include AudioVideo as well
Development An application for development
Education Educational software
Game A game
Graphics Application for viewing, creating, or processing graphics
Network Network application such as a web browser
Office An office type application
Science Scientific software
Settings Settings applications Entries may appear in a separate menu or as part of a "Control Center"
System System application, "System Tools" such as say a log viewer or network monitor
Utility Small utility application, "Accessories"

In addition, you could specify one or more from the longer list of Additional Categories.

Please test the result with desktop-file-validate and make sure it passes.

References:

@masc4ii
Copy link
Collaborator

masc4ii commented Oct 3, 2017

@probonopd : Do you know how to do that with linuxdeployqt or Qt? I have no idea.

@probonopd
Copy link

Yes, simply edit or create a desktop file and add the Categories= key there.
https://standards.freedesktop.org/desktop-entry-spec/latest/

@masc4ii
Copy link
Collaborator

masc4ii commented Oct 3, 2017

I would not recommend that, because on every build this is overwritten. The whole package is autocreated (as revast wrote some posts above).

@probonopd
Copy link

a MLVApp.desktop file with Exec=MLVApp line in it

This is not sufficient. A valid desktop file needs more lines in it than just this.

@revast
Copy link
Author

revast commented Oct 3, 2017

The whole package is autocreated (as revast wrote some posts above).

nope, this was created by hand, as linuxdeployqt failed to point the prefix right in qt.conf (or I did something wrong, actually the prefix line does not work at all, I tried numerous configurations)

Prefix = ./

So I made an AppRun script which sets the environment variables accordingly:

export APPDIR="$(dirname "$(readlink -f "$0")")" //dir where MLVApp resides
export APPPKG="$(basename "$APPIMAGE")"  //not used now, could be useful though
export LD_LIBRARY_PATH=lib:LD_LIBRARY_PATH
export QT_QPA_PLATFORMTHEME="fusion" 
export QT_PLUGIN_PATH=plugins:QT_PLUGIN_PATH
cd $APPDIR
./MLVApp -style=fusion

I had to set it to fusion or MLVApp would have had troubles on a vanilla xubuntu 17.10:
withoud doing so, it would look like

1

instead of

2

I am not entirely sure whats causing this... I tried to put all the theme - and style - plugins into the appimage beforehand. My goal was to ship the appimage with all the common theme and style engines for qt5, but this did not work out as expected - the KDE5 based ones want me to ship KDE libraries, and with the GTK one, I got an error:


QGtkStyle could not resolve GTK. Make sure you have installed the proper libraries.
QCommonStyle::drawComplexControl: Control 1 not handled

Now about the categories: Yeah I have missed that out, but that was because I was following the info in appimage wiki , where it also is missing, would be nice if somebody could fix it there, too.

Now what is that line

Categories=

useful for? It plays a role when the .desktop file is copied to ~/.local/share/applications, so that the app is shown under the right submenu in the system's applications list.
This could be easily scripted on first startup of the MLVApp' AppRun script. In fact there is some stub script which does exactly that, plus copying icon etc. on numerous AppImages).
The .desktop file also works in conjunction with appimaged, which also does this, but automatically for all appimages it finds, by watching folders like ~/Downloads.

I now also tried to fulfill the freedesktop appstream specifications, which is useful because all the appstores under linux (gnome's cinnamon's ...) are using this metadata. But I failed so far, with com.github.ilia3101.MLVApp.appdata.xml contents:

appimagetool squashfs-root-appstream/
Arch: 86_64
/home/hero/Projects/squashfs-root-appstream should be packaged as MLVApp-x86_64.AppImage
AppStream upstream metadata found in usr/share/metainfo/com.github.ilia3101.MLVApp.appdata.xml
I - com.github.ilia3101.MLVApp.appdata.xml:com.github.ilia3101.MLVApp.desktop:5
    The component summary should not end with a "." [A RAW converter,developerplayer 
    for Magic Lantern Video files and CinemaDNG sequences, with ProRes export.]

Validation was successful: infos: 1
squashfs-root-appstream/usr/share/metainfo/com.github.ilia3101.MLVApp.appdata.xml: 

failed to parse squashfs-root-appstream/usr/share/metainfo/com.github.ilia3101.MLVApp.appdata.xml: 

Error on line 11 char 9: <description> already set '​' and tried to replace with '
    '
Failed to validate AppStream information with appstream-util

@probonopd
Copy link

probonopd commented Oct 3, 2017

Now about the categories: Yeah I have missed that out, but that was because I was following the info in appimage wiki , where it also is missing, would be nice if somebody could fix it there, too.

Thanks for the hint, updated the wiki page.

Now what is that line Categories= useful for?

It places the application into the correct menu when used e.g., with the optional appimaged daemon, which registers applications with the system (menus, MIME types, icons, etc.).

I now also tried to fulfill the freedesktop appstream specifications, which is useful because all the appstores under linux (gnome's cinnamon's ...) are using this metadata.

Thanks 👍
Please file an issue here if you think you can't get the AppStream issue solved.

@ilia3101
Copy link
Owner

Anyway - a howto is missing for all platforms.
@masc4ii If you have time could you possibly put a non-specific howto (that works on most systems) for compiling QtApp on the read_me?
I promised to do it a few weeks ago, but I had many issues with getting it to compile on Qt and 10.13 :*(

@masc4ii
Copy link
Collaborator

masc4ii commented Oct 19, 2017

I know... but that is really hard. Especially for Linux you could write for every distro and version another readme. That really sucks. I tried on Ubuntu 12.04 and it is different to what sescho and revast wrote before.
In general it could be like that for Linux:

  • install Qt5 (minimum 5.6), ffmpeg (we use v3.3.2) and zlib (the steps to get these three items are different on all distros)
  • cd platform/qt/libpng16/
  • unpack libpng-1.6.31.tar.gz (don't know how to do in terminal)
  • ./configure make check sudo make install
  • cd..
  • qmake MLVApp.pro or equivalent (depending on distro and version and...)
  • make -j4 (for quad core)
  • ./mlvapp and have fun

Mac:

  • install XCode depending on your OSX
  • install Qt5 (minimum 5.6)
  • unpack libpng-1.6.31.tar.gz (don't know how to do in terminal)
  • cd platform/qt/libpng16/ ./configure make check sudo make install
  • unpack ffmpegOSX.zip in platform/qt/FFmpeg
  • open platform/qt/MLVApp.pro in QtCreator
  • go to tab project, add command line argument -j4 (for quad core) under build steps, uncheck ...DYLD_LIBRARY_PATH... under Run
  • Build and Start

Windows:

  • install Qt5 (minimum 5.6)
  • unpack ffmpegWin.zip in platform/qt/FFmpeg (and copy it later into build directory)
  • open platform/qt/MLVApp.pro in QtCreator
  • go to tab project, add command line argument -j4 (for quad core) under build steps, uncheck ...DYLD_LIBRARY_PATH... under Run
  • Build and Start

This should be it... but there will be differences on many systems...

@ilia3101
Copy link
Owner

Thanks for the info! Is Creator IDE not necessary, just enough to install Qt libraries?

I think what you have written is very useful, I've simply pasted it on the read_me, and if any issues / changes arise, it can easily be edited or fixed. It will be useful even how it is already.

@masc4ii
Copy link
Collaborator

masc4ii commented Oct 19, 2017

Creator makes editing and debugging a lot easier, because it is a superior IDE. But for just building you don't need it. In principle that should be the same on Win&OSX, but I did not try. On my old Ubuntu I did not get Creator to work :-P and audio does not work (driver problem) :-P hehehehe Maybe I need a newer Ubuntu for that.

@probonopd
Copy link

This is still an issue.

Reference:
AppImage/appimage.github.io#96

@masc4ii
Copy link
Collaborator

masc4ii commented Apr 1, 2018

Could you please explain your reference? I don't understand what you are doing there... sry...

@probonopd
Copy link

The desktop file is lacking a Categories= entry in the *.desktop file.

According to the menu spec,

By including one of the Main Categories in an application's desktop entry file, the application will be ensured that it will show up in a section of the application menu dedicated to this category. If multiple Main Categories are included in a single desktop entry file, the entry may appear more than once in the menu.

Hence, please add at least one of the following in the Categories= key.

Main Category Description Notes
AudioVideo Application for presenting, creating, or processing multimedia (audio/video)
Audio An audio application Desktop entry must include AudioVideo as well
Video A video application Desktop entry must include AudioVideo as well
Development An application for development
Education Educational software
Game A game
Graphics Application for viewing, creating, or processing graphics
Network Network application such as a web browser
Office An office type application
Science Scientific software
Settings Settings applications Entries may appear in a separate menu or as part of a "Control Center"
System System application, "System Tools" such as say a log viewer or network monitor
Utility Small utility application, "Accessories"

In addition, you could specify one or more from the longer list of Additional Categories.

Please test the result with desktop-file-validate and make sure it passes.

@masc4ii
Copy link
Collaborator

masc4ii commented Apr 1, 2018

I still don't understand - there is no *.desktop file in the repos... so where to add that?!

@probonopd
Copy link

probonopd commented Apr 1, 2018

Then that's the problem. Please create a proper desktop file.
https://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html

@probonopd
Copy link

probonopd commented Apr 1, 2018

This should do:

[Desktop Entry]
Type=Application
Exec=...
Comment=...
Name=...
Icon=...
Categories=...;

Please replace ... with the correct values for your application.

@masc4ii
Copy link
Collaborator

masc4ii commented Apr 1, 2018

And where do I add that in the repos (repos path)? Is there a Qt command to add it anywhere in the build as it is for OSX to add the info.plist file? Exec and Icon needs a path? But how do I know a path on any users computer?! This could be all or nothing... (sry, I am not deep enough in linux)

@masc4ii
Copy link
Collaborator

masc4ii commented Apr 1, 2018

[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=MLVApp
Comment=MLV processing application
Exec=?
Icon=?/MLVAPP.png
Terminal=false
Categories=AudioVideo;Video;

And now?

@probonopd
Copy link

Please use

Exec=(the name of your main executable, without a path)

and

Icon=MLVAPP

(without a path or suffix) assuming that your icon file is called MLVAPP.png.

The desktop file needs to go to (AppDir)/usr/share/applications/mlvapp.desktop.

@masc4ii
Copy link
Collaborator

masc4ii commented Apr 1, 2018

Okay, thanks:

[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=MLVApp
Comment=MLV processing application
Exec=mlvapp
Icon=MLVAPP
Terminal=false
Categories=AudioVideo;Video;

And how does linux find the icon file?
I think Qt will do a shadow build on linux too. So in this build directory I add the path you wrote with this desktop file, okay?! I'll search if Qt can do this - unfortunately I can't test if it works.

@masc4ii
Copy link
Collaborator

masc4ii commented Apr 1, 2018

I added the desktop file to the repos and tried to write a automated copy command for Qt. No idea if that works...

@probonopd
Copy link

Thanks. You can check by running the AppImage with the --appimage-extract option and seeing whether it is there.

@masc4ii
Copy link
Collaborator

masc4ii commented Apr 1, 2018

@probonopd : do you use Qt? I saw you have a repos for linuxdeployqt ... you are not able to try it out? The biggest problem should be to include ffmpeg, but as long as you don't export it maybe works without. It is just downloading, loading into QtCreator, configure and build. If you know Qt it is really simple.

@probonopd
Copy link

@masc4ii I am happy to help if the upstream authors package QtApp with linuxdeployqt and are running into issues. https://github.com/probonopd/linuxdeployqt/#using-linuxdeployqt-with-travis-ci should get them started.

@masc4ii
Copy link
Collaborator

masc4ii commented May 30, 2018

Tried out to build an app package:
https://github.com/ilia3101/MLV-App/releases/download/QTv0.16alpha/MLV.App.v0.16.alpha.Linux.x86_64.zip

Please try out... 😄
(exporting a file could be problematic, because ffmpeg is not in the package...)

@bouncyball-git
Copy link
Collaborator

Can not be run here ubuntu 16.04.

$ ./MLVApp.AppImage
./MLVApp.AppImage: /lib/x86_64-linux-gnu/libm.so.6: version GLIBC_2.27' not found (required by ./MLVApp.AppImage) ./MLVApp.AppImage: /lib/x86_64-linux-gnu/libc.so.6: version GLIBC_2.27' not found (required by /tmp/.mount_MLVAppNAm8fu/usr/bin/../lib/libpulsecommon-11.1.so)
./MLVApp.AppImage: /lib/x86_64-linux-gnu/libc.so.6: version GLIBC_2.25' not found (required by /tmp/.mount_MLVAppNAm8fu/usr/bin/../lib/libsystemd.so.0) ./MLVApp.AppImage: /lib/x86_64-linux-gnu/libc.so.6: version GLIBC_2.27' not found (required by /tmp/.mount_MLVAppNAm8fu/usr/bin/../lib/libsystemd.so.0)

Unfortunately I have GLIBC_2.23. I guess GLIBC also has to be included into AppImage.

@seescho
Copy link
Contributor

seescho commented May 30, 2018

Works here on openSUSE. Exporting, too.

@masc4ii
Copy link
Collaborator

masc4ii commented May 30, 2018

Thanks for your tests! If I remember right, there was an option to explicitely pack libs into the package... I'll try out tomorrow! It was created on Ubuntu 18.04 LTS.

@probonopd
Copy link

It needs to be created on Ubuntu 14.04 if it is supposed to run on all still-supported versions. Otherwise it will fail on all but the very newest distributions. Please see https://github.com/AppImage/AppImageKit/wiki/Creating-AppImages#creating-appimages-that-are-compatible-with-many-systems

@masc4ii
Copy link
Collaborator

masc4ii commented May 31, 2018

Thanks everybody! Made the same procedure on Ubuntu 14.04 - please try again!

@masc4ii
Copy link
Collaborator

masc4ii commented May 31, 2018

Yes it is.

@probonopd
Copy link

Looks good to me now. Thank you very much! 👍

@masc4ii
Copy link
Collaborator

masc4ii commented May 31, 2018

To build the app image, create an application directory appdir with this structure:

└── usr
    ├── bin
    │   └── mlvapp (compiled binary)
    ├── lib
    └── share
        ├── applications
        │   └── mlvapp.desktop (from qt path)
        └── icons
            └── hicolor
                └── 512x512 
                    └── apps 
                        └── MLVAPP.png (from qt/RetinaIMG path)

Get linuxdeployqt release from here: https://github.com/probonopd/linuxdeployqt
Make it executable using chmod a+x.
Now type linuxdeployqt-continuous-x86_64.AppImage path/to/appdir/usr/share/applications/mlvapp.desktop -appimage -qmake=pathToQmake/qmake.

@probonopd
Copy link

create an application directory appdir with this structure

Normally these commands should do this:

qmake CONFIG+=release PREFIX=/usr
make -j$(nproc)
make INSTALL_ROOT=appdir -j$(nproc) install ; find appdir/

By default, qmake .pro files generated by Qt Creator unfortunately don't support make install out of the box. In this case you will get

make: Nothing to be done for `install'.
find: `appdir/': No such file or directory

If qmake does not allow for make install or does not install the desktop file and icon, then you need to change your .pro file it similar to https://github.com/probonopd/FeedTheMonkey/blob/master/FeedTheMonkey.pro.

@masc4ii
Copy link
Collaborator

masc4ii commented May 31, 2018

Thanks!
I added to the .pro:

linux-g++ {
    isEmpty(PREFIX) {
        PREFIX = /usr
    }
    target.path = $$PREFIX/bin

    desktop.path = $$PREFIX/share/applications/
    desktop.files += mlvapp.desktop
    icon512.path = $$PREFIX/share/icons/hicolor/512x512/apps
    icon512.files += RetinaIMG/MLVAPP.png

    INSTALLS += icon512
    INSTALLS += desktop
    INSTALLS += target
}

And I changed the project config:
bildschirmfoto 2018-05-31 um 13 54 30

Now the appdir is generated automatically into the build directory. Then linuxdeployqt can be started as written above.

@bouncyball-git
Copy link
Collaborator

Now it works fine under Ubuntu 16.04 :)

Is there a way to set the default MLV App icon of this AppImage?

@masc4ii
Copy link
Collaborator

masc4ii commented May 31, 2018

For me the MLVApp icon is only shown in the taskbar, when the app is opened. The appimage icon itself is different... 😢

@bouncyball-git
Copy link
Collaborator

bouncyball-git commented May 31, 2018

Yes exactly.

Edit: here is the related link

@probonopd
Copy link

If you want the icon of the AppImage file to look nicely, you currently need to have the optional appimaged daemon running (which does desktop integration). Also, the AppImage needs to have icons in usr/share/icons/hicolor/<resolution>/apps/<filename>.

@masc4ii
Copy link
Collaborator

masc4ii commented May 31, 2018

So it is not that easy atm... okay.
The icon is located in this folder. When app runs, the icon is shown.

@masc4ii
Copy link
Collaborator

masc4ii commented Jun 1, 2018

@probonopd : how can I add a second executable to the appimage, in a way this one can be started from the main application? The executable binary (ffmpeg) is now appdir/usr/bin/ffmpeg, the appimage is also 30MB bigger (as expected), but when starting it from the main app, it tells "sh: 1: ffmpeg: not found".
On OSX I do the same with macdeployqt - no problem.

@masc4ii
Copy link
Collaborator

masc4ii commented Jun 1, 2018

Sorry for asking... I think I got it... was my fault.

@masc4ii
Copy link
Collaborator

masc4ii commented Jun 1, 2018

ffmpeg is now included in the appimage as well. (Same download link again) Now, MLVApp can export on Linux systems where no ffmpeg was installed before...

@bouncyball-git
Copy link
Collaborator

Yup, working :)

@masc4ii
Copy link
Collaborator

masc4ii commented Jun 6, 2018

As fastest qt lib bouncyball and me found 5.9.2 (at least faster than 5.9.5 and 5.7.1), so I'll take this version for future appimage releases. This thread should be finished now... close.

@masc4ii masc4ii closed this as completed Jun 6, 2018
@masc4ii
Copy link
Collaborator

masc4ii commented Jun 6, 2018

Btw: thanks everybody for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants