Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Deploy Application in Linux



  • I have successfully deployed my application in windows using windeployqt and now I am looking to deploy in linux.

    I followed a tutorial on how to do it using qinuxdeployqt but I got an error about " The host system is too new" which I could get past. In the output threre was this link to one repo issue.
    In the discussion there were some mentions about these two option: -unsupported-bundle-everything and -unsupported-allow-new-glibc but from what I read:

    I am open to adding options, as long as it is very clear that those options are neither recommended nor supported by me. As such, I would welcome pull requests that implement the following:

    -unsupported-bundle-everything: Bundles ALL dependency libraries, down to and including the ld-linux.so loader and glibc. This will allow applications built on newer systems to run on older target systems, but it is not recommended since it leads to bundles that are larger than necessary
    -unsupported-allow-new-glibc: Allows linuxdeployqt to run on distributions newer than the oldest still-supported Ubuntu LTS release. This will result in AppImages that will not run on all still-supported distributions, and is neither recommended nor tested or supported

    Meaning that I couldn't get past that error with the latest release and I am not really willing to reinstall my system to the oldest still-supported Ubuntu LTS release. I found what he is trying to accomplish with that rule noble but at the same too restricted for normal use.

    Anyway, I went on to try linuxdeploy but that one I just couldn't find how to install, not even how to build it(tried to build it at some point but I was not successful).

    So I went on to another alternative, CQtDeployer, I installed and tried to run it but don't matter how I tried it always gave me 'missing arguments' errors and there are two few examples on how to use it and no guide on how to deploy an application right from start.

    So, I came to find a tutorial on how to deploy using linuxdeployqt, in the tutorial the same errors I got was found too and was solved using an older release instead, so I did that and the error about host being too new was gone, tried to use it to deploy my app and it kept giving me this error:

    ERROR: ldd outputLine: "libicui18n.so.56 => not found"
    

    I couldn't find a solution to that.
    I have visited a lot of forums and followed many tutorials but every one of them suggests using one of the tree tools I mentioned above.

    But I think that these 3 tools are fairly new, so I ask how Qt apps were being deployed in linux before them. How can I successfully deploy my app without them.

    I have spent hours trying to deploy my app with not luck.

    As a last resource, I am now trying to manually copy all the dependencies into the my executable directory.


  • Lifetime Qt Champion

    @hbatalha said in Deploy Application in Linux:

    Meaning that I couldn't get past that error with the latest release

    Why do you think so? The author simply states that he does not "support" these parameters, means - he does not guarantee anything. You should try.



  • @jsulm said in Deploy Application in Linux:

    he does not guarantee anything. You should try.

    I tried them, they are not implemented yet.



  • Just a little update, I did go to my last resource, copied all the dependencies manually, used the Qt Installer Framework to create a .run file. I was able to run installer, install the application, created desktop entry.

    But, when I tried to run the program in a another machine, the machine complained about no finding the .so files even though they are there in the same folder.

    So, I am looking for the solution of this problem.

    Any idea, anyone?



  • @hbatalha said in Deploy Application in Linux:

    But, when I tried to run the program in a another machine, the machine complained about no finding the .so files even though they are there in the same folder.

    So, I am looking for the solution of this problem.

    Any idea, anyone?

    Windows does always look first next to the executable, which is not the way in Unix/Linux. When linking, either the -rpath option is use and then the same relative path must be used, or the libraries are simply loaded from the system (i.e. /usr/lib64 or your system's equivalent), or you can specify additional directories using the LD_LIBRARY_PATH environment variable.
    If -rpath has been used, it can be tuned afterwards (but I can't remember the tool from the top of my head).



  • For completeness, the tool I was mentioning in my previous post is chrpath.



  • @JohanSolo I checked and it seems to be what I need.

    So I am trying it but I can't seem to get it working.

    I followed this tutorial but that doesn't work when change the rpath.
    My problem is in how I change the path, how to write the correct path, I visited different forums and I found people writing different syntaxes each time:

    • chrpath -r $ORIGIN/lib myexecutable
    • chrpath -r '$\ORIGIN/lib' myexecutable
    • chrpath -r '$\ORIGIN' myexecutable
    • chrpath -r $\ORIGIN/lib myexecutable
    • chrpath -r "$\ORIGIN/lib" myexecutable
    • chrpath -r '$\ORIGIN/lib' myexecutable

    These are some of the commands I tried, none worked. The files the machine is asking for are in my lib folder



  • @hbatalha
    You've told us the shared libraries are in the same directory as your executable file, but now you're telling they are in your lib folder (whatever that means). So please clarify where your shared libraries are.

    If they are in the same folder, then you should use:
    chrpath -r "$ORIGIN" myexecutable
    if they are in a lib subfolder, then the command reads:
    chrpath -r "$ORIGIN/lib" myexecutable



  • I recommend integrating rpath directly into the build with linker flags, not hacking on the files after they are built.



  • @Phil-K said in Deploy Application in Linux:

    I recommend integrating rpath directly into the build with linker flags, not hacking on the files after they are built.

    I would recommend that too, but sometimes (we don't know the OP's situation) the libraries are in that folder at build time but will be located in this folder when deployed. In that case "hacking" the binaries is a cleaner option.



  • @JohanSolo If he's not building a destination tree that mirrors the way he wants to install the files, he's doing it wrong. If he is doing that, then configure the build system to use rpath and $ORIGIN with the appropriate linker flags. I would turn to chrpath as a last resort, not an opening idea. It's quite common also to deploy wrappers that set the library path and then run the program. There's a lot to consider all in all, it's a non-trivial rabbit hole that brings in things like licensing, rpath, runpath, origin and other considerations such as allowing the user to run a different Qt runtime, etc.



  • @JohanSolo said in Deploy Application in Linux:

    So please clarify where your shared libraries are.

    Sorry for the lack of clarification, my libraries are in the lib folder, the lib folder is in the same directory as my executable.



  • @Phil-K said in Deploy Application in Linux:

    I recommend integrating rpath directly into the build with linker flags, not hacking on the files after they are built.

    I did that that, but I am still not sure what the correct syntax is, that's why I tried different ones as shown above.



  • @JohanSolo said in Deploy Application in Linux:

    but sometimes (we don't know the OP's situation) the libraries are in that folder at build time but will be located in this folder when deployed

    Please elaborate more on this kind of situation.



  • @Phil-K said in Deploy Application in Linux:

    If he's not building a destination tree that mirrors the way he wants to install the files, he's doing it wrong

    "Building a destination tree", what exactly is meant by that in the statement. Sorry this is my first time programming in a linux environment (programming isn't the most accurate term here since I am only compiling my application in linux and trying to deploy there, all the code was written in windows environment).



  • @hbatalha said in Deploy Application in Linux:

    @JohanSolo said in Deploy Application in Linux:

    but sometimes (we don't know the OP's situation) the libraries are in that folder at build time but will be located in this folder when deployed

    Please elaborate more on this kind of situation.

    Depending on how you build your library and executable, they might end up all in the same output directory, e.g. /home/johndoe/build-myproject-Qt5.15-Release. Now, if the linker flag -rpath was specified, the executable will try to load the shared library from /home/johndoe/build-myproject-Qt5.15-Release, which is fine when you just run your program, but not for deployed executable. In that case, you can:

    • set the -rpath correctly when compiling your executable as @Phil-K suggested;
    • use chrpath as explained above.

    If you only set the "final" path to -rpath (i.e. $ORIGIN/lib), then your executable might not be able to run outside you IDE (but several paths can be specified, separated with colons, i.e. :).



  • @JohanSolo said in Deploy Application in Linux:

    If you only set the "final" path to -rpath (i.e. $ORIGIN/lib), then your executable might not be able to run outside you IDE

    Are you saying if I use this command chrpath -r "$ORIGIN/lib" myexecutable on my executable then it will not run outside my IDE.



  • @hbatalha said in Deploy Application in Linux:

    Are you saying if I use this command chrpath -r "$ORIGIN/lib" myexecutable on my executable then it will not run outside my IDE.

    In my example, all binaries (i.e. executable and libraries) are located in the same directory, therefore the shared libraries won't be found when running the executable, as there is no lib subfolder (or it is empty).



  • Sorry for the late reply, I've working on the app and I do it on windows, I go to linux only to deploy it

    @JohanSolo said in Deploy Application in Linux:

    @hbatalha
    You've told us the shared libraries are in the same directory as your executable file, but now you're telling they are in your lib folder (whatever that means). So please clarify where your shared libraries are.

    If they are in the same folder, then you should use:
    chrpath -r "$ORIGIN" myexecutable
    if they are in a lib subfolder, then the command reads:
    chrpath -r "$ORIGIN/lib" myexecutable

    I am still unable to get it to work.

    What I did: I compiled the programs , got its excutable(with the wrong rpath) and put it in a directory where I copied the .so files into the lib folder in that directory and changed the rpath with chrpath, then tried to run it but still asking for those .so files



  • So please, give us:

    • the output of ls -R, run from the directory where your exe is located
    • the output of ldd, run on your exe
    • the output of chrpath -l, run on your exe

    There must be something wrong or at least not understood by us in your setup, it should work.



  • @hbatalha said in Deploy Application in Linux:

    So I went on to another alternative, CQtDeployer, I installed and tried to run it but don't matter how I tried it always gave me 'missing arguments' errors and there are two few examples on how to use it and no guide on how to deploy an application right from start.

    Show the command you used when running cqtdeployer .
    Here's the documentation on how to use cqtdeployer.
    This is guide on how to deploy an application right from start.



  • @JohanSolo sorry for the really late reply, I got really busy with school and I put this aside for a while.

    I found out what I was doing wrong, as it turns out, the problem was that all .so files in my lib folder were copied as symlink when I copied them directly. So I copied the entire lib folder from the Qt installation and then removed the ones the program didn't need.

    And in the .pro file I just added:

    unix:{
        # suppress the default RPATH if you wish
        QMAKE_LFLAGS_RPATH=
    
        QMAKE_LFLAGS += "-Wl,-rpath,\'\$$ORIGIN/lib\'"
    }
    

    Thanks for the time and patience



  • @hbatalha said in Deploy Application in Linux:

    I found out what I was doing wrong

    great! please don't forget to mark your post as solved.


Log in to reply