Solved Deploy Application in Linux
-
@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.:
). - set the
-
@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 alib
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.
- the output of
-
@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.