how to link with "so" files
-
We developing an Qt-application.(boot2qt 5.9.1)
It link with "libaaa.so" file.In this case is ok that so-file is in "(root)lib/" folder.
The Qt-application can like with the so-file.However, in other case isn't ok that so-file is in "home/root/abc/lib"
folder.
Of cause I could set "home/root/abc/lib" in "LD_LIBRARY_PATH"
or "PATH".
But when I compile in this situation, I can see this message on Qt-Creator-
Output
: error while loading shared libraries: libthincapayment.so: cannot open
shared object file: No such file or directoryHow can I use so-file without "(root)lib/" folder?
Thanks. -
@nishiokas You need to specify the path where linker should look for the library using -L parameter.
See https://doc.qt.io/qt-5/qmake-variable-reference.html#libs
Or are you talking about running your app? -
@nishiokas So, then it has nothing to do with building.
This is a runtime issue. If you put the lib into a folder which is not searched for libraries by the system then you have to set LD_LIBRARY_PATH before starting the app (not before building it!) or put the lib next to the exe (in same folder). -
@jsulm said in how to link with "so" files:
put the lib next to the exe (in same folder)
This works for Windows but not Linux.
For Linux, you'd need to use
chrpath
orpatchelf
to set your application's RUNPATH (or RPATH) to$ORIGIN
if you want it to search its folder for libraries.