Create portable Qt application for linux



  • Hello my friendly Qt devs,
    i have (a maybe stupid) question. I have developed my Qt5 application on windows only and have just be in touch with linux for a few days. I windows i could easily create a portable application, with a few very simple step.

    Release -> copy .exe to a folder -> add missing .dlls to folder -> create subfolder platforms -> add .dll

    With this i had a portable application which could be started even on PCs which have never seen Qt bevor.
    I would like to do the same for linux. At the moment i have an Raspberry Pi, on which i have compiled Qt5, as my developing platform. I have already created my executable with

    make -clean -> qmake -config release -> make

    After this i have a folder with a executable and i am able to start it on this system. I have read that the .dll in windows are called .so in linux and that i can find all dependencies with

    ldd ./application

    I have no other linux system to test this, so would it be enough to copy all .so into this folder (like in windows?) and the executable will find them? I have read that in linux the .so should be installed in the /usr/lib directory, but i want to start the application without any install.

    The desired aim is to plug a usb in, start the application and be ready to go.



  • There are two options to test your installation

    1. Install VirtualBox or another virtual machine and install Linux under VirtualBox
      You will have clean system and can test usbdrive

    2. Copy exec to another directory and try to run it
      a. Copy you executable to some directory
      b. Make sure that ldd ./yourexec shows missing libraries
      c. Copy all necessary libraries and try again.

    If you will find that running exec in the same directory with the libraries does not work then create a shell script to setup LD_LIBRARY_PATH and start your app.
    @
    !#/bin/sh
    export LD_LIBRARY_PATH=./:$LD_LIBRARY_PATH
    ./yourexec
    @
    NOTE: This example will not find your exec if started from another directory.


  • Lifetime Qt Champion

    Hi,

    "Here":http://qt-project.org/doc/qt-5/linux-deployment.html#creating-the-application-package you can find the explanation on how to do it



  • I also use a USB thumb drive to copy Qt apps for Linux, sometimes I forget to export LD_LIBRARY_PATH and my app does not launch :-(

    But I want the same behavior as in Windows (no script or export needed). I change the "RPATH":http://en.wikipedia.org/wiki/Rpath setting of my Qt app, so that it looks for the .so (DLL) files in the same directory as itself. I use the chrpath command for this, I've written about it "here":http://www.tripleboot.org/?p=138#Linux



  • Thank you very very much, this helps a great deal :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.