# SER Player: AppImage script for Qt project

**URL:** <https://discourse.appimage.org/t/ser-player-appimage-script-for-qt-project/41>\
**Category:** Creating AppImages\
**Created:** [August 14, 2016, 9:12pm UTC](https://discourse.appimage.org/t/ser-player-appimage-script-for-qt-project/41 "2016-08-14T21:12:33Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![cgarry](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.appimage.org/cgarry/32/114_2.png) [@cgarry](https://discourse.appimage.org/u/cgarry)\
**Post date:** [August 14, 2016, 9:12pm UTC](https://discourse.appimage.org/t/ser-player-appimage-script-for-qt-project/41/1 "2016-08-14T21:12:34Z")

</div>

I want to share the script that I am now using to create AppImages for my Qt C++ project ‘SER Player’. This script was developed with and original recipe and lots of help from Simon.

This script is now working very well, generating a 64-bit or 32-bit AppImage depending on which version of Linux is running. It should be very simple to modify the script for other Qt C++ projects so it could be used as a starting point for others which is one reason that I am posting this.

Another reason for posting is others might be able to suggest fixes and improvements.

The ‘SER Player’ project is here:

> **[cgarry/ser-player](https://github.com/cgarry/ser-player)**
>
> A simple video player for playing SER files used for solar, lunar and planetary astronomy-imaging. - cgarry/ser-player

To produce an AppImage from the project,the following should be entered at the command line:

cd ser-player qmake CONFIG+=release  
 make cd linux\_appimage  
$ ./make\_appimage.sh

This will generate an AppImage in the linux\_appimage directory.

This is the current make\_appimage.sh script:

```auto
#!/bin/bash

copy_libs_for_binary()
{
    echo "Copying libs for binary $1 to $2"

    libs=$(ldd $1)

    lib=()
    mapfile -t lib <<< "$libs"
    for lib in "${lib[@]}"
    do
        #echo "lib: ${lib}"
        a=( $lib )
        count=${#a[@]}
        if ((count > 3)); then
            cp -n ${a[2]} $2
            sub_libs=$(ldd ${a[2]})
            sub_lib=()
            mapfile -t sub_lib <<< "$sub_libs"
            for lib2 in "${sub_lib[@]}"
            do
                #echo " lib2: ${lib2}"
                a2=( $lib2 )
                count2=${#a2[@]}
                if ((count2 > 3)); then
                    cp -n ${a2[2]} $2
                fi
            done
        fi
    done
}

# Run the get_qt_details.sh script to set details of the Qt installation and the architecture
# This script is generated by qmake and sets the $QT_INSTALL_DIR and $SYS_ARCH variables.
this_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
source $this_dir/get_qt_details.sh

# Create temp directory to work in when creating the AppImage
rm -rf temp
mkdir temp
cd temp

# Checkout and build AppImageKit
git clone https://github.com/probonopd/AppImageKit.git
./AppImageKit/build.sh

# Get the AppImage script functions file
wget -q https://github.com/probonopd/AppImages/raw/master/functions.sh -O ./functions.sh
. ./functions.sh

# Create the AppImage directory structure
mkdir -p ser-player.AppDir/usr/bin
#mkdir -p ser-player.AppDir/usr/lib/ser-player/libs
mkdir -p ser-player.AppDir/usr/lib/ser-player/platforms
mkdir -p ser-player.AppDir/usr/lib/ser-player/plugins/imageformats
mkdir -p ser-player.AppDir/usr/share/applications
mkdir -p ser-player.AppDir/usr/share/icons/hicolor/128x128/apps
mkdir -p ser-player.AppDir/usr/share/mime/packages

# Copy ser-player executable file into place and strip it
cp ../../bin/ser-player ser-player.AppDir/usr/lib/ser-player/
strip -s ser-player.AppDir/usr/lib/ser-player/ser-player
chmod 0755 ser-player.AppDir/usr/lib/ser-player/ser-player
chrpath -d ser-player.AppDir/usr/lib/ser-player/ser-player

# Copy shell script and wrapper files
cp ../files/ser-player ser-player.AppDir/usr/bin/
cp ../files/ser-player.wrapper ser-player.AppDir/usr/bin/

# Copy files in share directories
cp ../files/share/ser-player.desktop ser-player.AppDir/usr/share/applications/
cp ../files/ser-player.png ser-player.AppDir/usr/share/icons/hicolor/128x128/apps/
cp ../files/share/ser-player.xml ser-player.AppDir/usr/share/mime/packages/

# Copy file into top level of AppDir
cp ./AppImageKit/AppRun ser-player.AppDir/
cp ../files/ser-player.desktop ser-player.AppDir/
cp ../files/ser-player.png ser-player.AppDir/

# Copy Qt platform plugin to AppDir
cp ${QT_INSTALL_DIR}/plugins/platforms/libqxcb.* ser-player.AppDir/usr/lib/ser-player/platforms/

# Copy other Qt plugins to AppDir
cp ${QT_INSTALL_DIR}/plugins/imageformats/libqjpeg.* ser-player.AppDir/usr/lib/ser-player/plugins/imageformats/
cp ${QT_INSTALL_DIR}/plugins/imageformats/libqtiff.* ser-player.AppDir/usr/lib/ser-player/plugins/imageformats/

# Copy all required libs to AppDir
copy_libs_for_binary ../../bin/ser-player ser-player.AppDir/usr/lib/
copy_libs_for_binary ${QT_INSTALL_DIR}/plugins/platforms/libqxcb.so ser-player.AppDir/usr/lib/
copy_libs_for_binary ${QT_INSTALL_DIR}/plugins/imageformats/libqjpeg.so ser-player.AppDir/usr/lib/
copy_libs_for_binary ${QT_INSTALL_DIR}/plugins/imageformats/libqtiff.so ser-player.AppDir/usr/lib/

# Remove excluded libraries
cd ser-player.AppDir/usr/lib/
delete_blacklisted
cd ../../..

# Strip all libs and change permissions
strip -s ser-player.AppDir/usr/lib/lib*
chmod 0644 ser-player.AppDir/usr/lib/lib*

# Get the glibc version required using the glibc_need() function from the AppImageKit functions.sh 
cd ser-player.AppDir
GLIBC_NEEDED=$(glibc_needed)
cd ..

#wget -c "https://github.com/probonopd/AppImageKit/releases/download/5/AppImageAssistant" # (64-bit)

./AppImageKit/AppImageAssistant ./ser-player.AppDir/ ../ser-player-x.x.x-glibc${GLIBC_NEEDED}-${SYS_ARCH}.AppImage

cd ..

```

Cheers,  
Chris

---

<div class="post-metadata">

**Author:** ![hideout](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.appimage.org/hideout/32/4_2.png) [@hideout](https://discourse.appimage.org/u/hideout)\
**Post date:** [August 15, 2016, 10:19am UTC](https://discourse.appimage.org/t/ser-player-appimage-script-for-qt-project/41/2 "2016-08-15T10:19:01Z")

</div>

thanks @cgarry!  
i was searching for something something similar

---

<div class="post-metadata">

**Author:** ![lock042](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.appimage.org/lock042/32/652_2.png) [@lock042](https://discourse.appimage.org/u/lock042)\
**Post date:** [August 15, 2016, 10:21am UTC](https://discourse.appimage.org/t/ser-player-appimage-script-for-qt-project/41/3 "2016-08-15T10:21:42Z")

</div>

Thank you Chris.  
Hoping someone will do the same with gtk 😉

---

<div class="post-metadata">

**Author:** ![probono](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.appimage.org/probono/32/81_2.png) [@probono](https://discourse.appimage.org/u/probono)\
**Post date:** [August 15, 2016, 9:28pm UTC](https://discourse.appimage.org/t/ser-player-appimage-script-for-qt-project/41/4 "2016-08-15T21:28:53Z")

</div>

Thanks Chris.

Some Qt-based app projects on GitHub use Travis CI for continuous builds (for testing), and I have written a script that allows them to bundle and upload the build artefacts as an AppImage on each build: [Here](https://github.com/search?q=%22For+more+information%2C+see+http%3A%2F%2Fappimage.org%2F%22&ref=searchresults&type=Code&utf8=%E2%9C%93).

---

<div class="post-metadata">

**Author:** ![cgarry](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.appimage.org/cgarry/32/114_2.png) [@cgarry](https://discourse.appimage.org/u/cgarry)\
**Post date:** [August 16, 2016, 8:07am UTC](https://discourse.appimage.org/t/ser-player-appimage-script-for-qt-project/41/5 "2016-08-16T08:07:07Z")

</div>

Simon,

I wish I had spotted those scripts before I wrote mine, they are a much better starting point than the .deb conversion script I used! Still, I think it has been a good learning experience for me to work through everything from scratch as it were.

A couple of things I noticed about these scripts when I quickly looked at them, at least the two I looked at:

- These scripts seems to have the Qt plugins version and path hard coded.
- They seem to be 64-bit only.

But thanks for pointing them out, I plan to update my script based on these scripts in order to tidy it up and make it look more presentable.

Cheers,  
Chris

---

<div class="post-metadata">

**Author:** ![probono](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.appimage.org/probono/32/81_2.png) [@probono](https://discourse.appimage.org/u/probono)\
**Post date:** [August 16, 2016, 3:12pm UTC](https://discourse.appimage.org/t/ser-player-appimage-script-for-qt-project/41/6 "2016-08-16T15:12:04Z")

</div>

Hi Chris,

thanks for having a go at improving these scripts - possibly we can make a generic version together that can be used by 3rd party projects to easily generate AppImages from Qt based Travis CI builds they are already doing. I have noticed that especially Qt based app projects seem to be interested in AppImage, as often they are interested in building one app for all 3 major operating systems.

So, i’m very interested in what you can make from these – especially the Qt version and plugins is something I wanted to do in a more generic way but didn’t figure out yet.

Best,  
Simon

---

<div class="post-metadata">

**Author:** ![cgarry](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.appimage.org/cgarry/32/114_2.png) [@cgarry](https://discourse.appimage.org/u/cgarry)\
**Post date:** [August 16, 2016, 10:41pm UTC](https://discourse.appimage.org/t/ser-player-appimage-script-for-qt-project/41/7 "2016-08-16T22:41:37Z")

</div>

Yes, I think a generic script for Qt projects would be of great interest to Qt users who choose Qt so they could support Linux, Windows and OS X.

I have just released v1.6.0 of SER Player with AppImages provided for the Linux versions. I am pleased that Linux support is no longer restricted to Debian based distributions.

> **[SER Player - PIPP Planetary Imaging PreProcessor](https://sites.google.com/site/astropipp/ser-player)**
>
> PIPP Planetary Imaging PreProcessor home

Cheers,  
Chris

---

<div class="post-metadata">

**Author:** ![probono](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.appimage.org/probono/32/81_2.png) [@probono](https://discourse.appimage.org/u/probono)\
**Post date:** [August 17, 2016, 6:17pm UTC](https://discourse.appimage.org/t/ser-player-appimage-script-for-qt-project/41/8 "2016-08-17T18:17:25Z")

</div>

Hi Chris, on the SER Player homepage it still says “SER Player is an open source application with pre-built versions available for Windows, OS X and **Debian Linux** (Download links below).” I think the “Debian” can be removed now 🙂

---

<div class="post-metadata">

**Author:** ![cgarry](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.appimage.org/cgarry/32/114_2.png) [@cgarry](https://discourse.appimage.org/u/cgarry)\
**Post date:** [August 17, 2016, 9:53pm UTC](https://discourse.appimage.org/t/ser-player-appimage-script-for-qt-project/41/9 "2016-08-17T21:53:44Z")

</div>

Good catch thanks, page updated!

---

<div class="post-metadata">

**Author:** ![dridk](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.appimage.org/dridk/32/44_2.png) [@dridk](https://discourse.appimage.org/u/dridk)\
**Post date:** [January 18, 2017, 8:26am UTC](https://discourse.appimage.org/t/ser-player-appimage-script-for-qt-project/41/10 "2017-01-18T08:26:20Z")

</div>

I m using linuxdeployqt now :

> **[probonopd/linuxdeployqt](https://github.com/probonopd/linuxdeployqt)**
>
> Makes Linux applications self-contained by copying in the libraries and plugins that the application uses, and optionally generates an AppImage. Can be used for Qt and other applications - probonop...
