Krasnal
Krasnal

Reputation: 85

How to link properly shared linux libraries in qt?

I'd like to run my program on different computer which doesn't have any installed libs. I build my program in QT with openCV and copied all needed .so libs to folder with all my files. Next I changed paths in QT .pro to

INCLUDEPATH += ../

LIBS += -L../ -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_core.

I compiled that on my computer (linux) and it worked but I want it to work on another computer without compilation. On my friend's computer, binary doesnt work. I get error:

./displayImage: error while loading shared libraries: libopencv_highgui.so.3.1: cannot open shared object file: No such file or directory

Upvotes: 0

Views: 911

Answers (2)

Fabius Wiesner
Fabius Wiesner

Reputation: 926

You can also add a file <whatever>.conf in /etc/ld.so.conf.d and put one or more rows with the pathnames of your libraries.

Then run ldconfig. This is needed only once.

Upvotes: 1

Victor Tran
Victor Tran

Reputation: 516

Set the LD_LIBRARY_PATH environment variable to the directory that you're running it from.

If your files are located in /home/abc/cool/program/displayImage (and that folder contains all the .so files that your program needs to run)

$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/abc/cool/program/
$ ./displayImage

Upvotes: 2

Related Questions