Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Deploy Application in Linux
Forum Updated to NodeBB v4.3 + New Features

Deploy Application in Linux

Scheduled Pinned Locked Moved Solved General and Desktop
23 Posts 6 Posters 3.5k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Phil K

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

    H Offline
    H Offline
    hbatalha
    wrote on last edited by
    #13

    @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.

    1 Reply Last reply
    0
    • JohanSoloJ JohanSolo

      @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.

      H Offline
      H Offline
      hbatalha
      wrote on last edited by
      #14

      @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.

      JohanSoloJ 1 Reply Last reply
      0
      • P Phil K

        @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.

        H Offline
        H Offline
        hbatalha
        wrote on last edited by
        #15

        @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).

        1 Reply Last reply
        0
        • H hbatalha

          @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.

          JohanSoloJ Offline
          JohanSoloJ Offline
          JohanSolo
          wrote on last edited by
          #16

          @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. :).

          `They did not know it was impossible, so they did it.'
          -- Mark Twain

          H 1 Reply Last reply
          1
          • JohanSoloJ JohanSolo

            @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. :).

            H Offline
            H Offline
            hbatalha
            wrote on last edited by
            #17

            @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.

            JohanSoloJ 1 Reply Last reply
            0
            • H hbatalha

              @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.

              JohanSoloJ Offline
              JohanSoloJ Offline
              JohanSolo
              wrote on last edited by
              #18

              @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).

              `They did not know it was impossible, so they did it.'
              -- Mark Twain

              1 Reply Last reply
              1
              • H Offline
                H Offline
                hbatalha
                wrote on last edited by
                #19

                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

                1 Reply Last reply
                0
                • JohanSoloJ Offline
                  JohanSoloJ Offline
                  JohanSolo
                  wrote on last edited by
                  #20

                  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.

                  `They did not know it was impossible, so they did it.'
                  -- Mark Twain

                  H 1 Reply Last reply
                  2
                  • EndrII 0E Offline
                    EndrII 0E Offline
                    EndrII 0
                    wrote on last edited by
                    #21

                    @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.

                    1 Reply Last reply
                    2
                    • JohanSoloJ JohanSolo

                      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.

                      H Offline
                      H Offline
                      hbatalha
                      wrote on last edited by
                      #22

                      @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

                      Pablo J. RoginaP 1 Reply Last reply
                      0
                      • H hbatalha

                        @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

                        Pablo J. RoginaP Offline
                        Pablo J. RoginaP Offline
                        Pablo J. Rogina
                        wrote on last edited by
                        #23

                        @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.

                        Upvote the answer(s) that helped you solve the issue
                        Use "Topic Tools" button to mark your post as Solved
                        Add screenshots via postimage.org
                        Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                        1 Reply Last reply
                        1

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved