Answer the question
In order to leave comments, you need to log in
How to make a program run in Linux look for libraries next to it?
Didn't work on Linux at all. And now I have written a program in Qt 5 and I want to distribute it as a folder with an executable file and libraries. As far as I understand, by default, when running an executable file, dynamic libraries are not searched next to isp. file. Now I did this: I
created a folder with the necessary dynamic libraries like /home/linux/myLibs,
And I created a configuration file indicating that it is necessary to look for libs, including in this folder:
sudo gedit /etc/ld.so.conf.d/MyLibs .conf
contents of MyLibs.conf: /home/linux/myLibs
This works .
Why doesn't the following option work?:
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QString app_path = QCoreApplication::applicationDirPath();
QString abs_app_path = QDir(app_path).absolutePath();
QString p1 = abs_app_path + "/intel64";
QString p2 = abs_app_path + "/qtlibs";
QCoreApplication::addLibraryPath(p1);
QCoreApplication::addLibraryPath(p2);
...
Answer the question
In order to leave comments, you need to log in
Build a normal package with dependencies. Don't trash the user's system with your libraries.
And your version does not work because by the time the program is launched, all these libraries should already be found and loaded.
QMAKE_LFLAGS +='-Wl,-rpath,\'\$$ORIGIN/\',-z,origin'
$ORIGIN - path to the executable, calculated at runtime, not during linking.
The "$" at the beginning needs shell and make protection.
It's not entirely clear why this is needed, but I think it's better to make libraries statistical linking.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question