V
V
Vladimir Bershov2015-01-16 13:50:41
linux
Vladimir Bershov, 2015-01-16 13:50:41

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

6 answer(s)
A
Armenian Radio, 2015-01-16
@gbg

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.

J
jcmvbkbc, 2015-01-16
@jcmvbkbc

export LD_LIBRARY_PATH=. canceled already?

D
demiol, 2015-01-18
@demiol

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.

A
asd111, 2015-01-16
@asd111

rpath

P
poxvuibr, 2015-01-16
@poxvuibr

It's not entirely clear why this is needed, but I think it's better to make libraries statistical linking.

I
index0h, 2015-01-17
@index0h

you can use static libraries.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question