shared lib problem for cross compile
-
Dear All,
I am trying to cross compile (host ubuntu and client is raspi4) a simple program that uses some libfiles. Same libfiles are stored at sysroot/lib directory (/home/abc/example/src) and same sourcelibfiles are at Desktop directory(/home/d/Desktop/dnm/sysroot/lib). At src.pro file , used lib files are defined as LIBS+=$$PRO_FILE_PWD/sysroot/libs INCLUDEPATH+=$$PRO_FILE_PWD/sysroot/include. After compiling process finished, executable app file copied to client at /home/d/Desktop/dnm/app. When run it, gives cant find shared lib but this file also at /home/d/Desktop/dnm/sysroot/lib.
As a result, for crosscompile process if we use any shared lib (copied from source to sysroot), how can we define it at src.pro to find same file when it is executed at client side.
Best regards,
Metin
-
@metind said in shared lib problem for cross compile:
LIBS+=$$PRO_FILE_PWD/sysroot/libs
This likely bakes the library path into the executable (you can check with
ldd
). Since in target device the library is in system-wide location, you can simply do this:LIBS+=-lyourLibName
And app will look foir the library in standard locations.
-
-
@metind said in shared lib problem for cross compile:
Pls check src.pro. When I use as you said I'm getting this error and include path also needed to be defined as full path.
Your screenshot does not contain any
INCLUDEPATH
. You need to add it! The include path is only used during compilation, it is not used at all at runtime. So you can safely use full path there. I was only talking aboutLIBS
.I couldn't find any way how can I define lib and includepath at host part and can work at client side.
-
OK, please do this:
- add full path to
LIBS
as well (it compiles, as you said in original post) - run
ldd
on resulting binary - post results here
- verify that the library on target system has the same file name
The output should show where the operating system is looking for the library, and under what name.
- add full path to
-
Ah OK, now I get it. Here are some solutions:
- move the libs to OS-wide directory, like
/usr/lib
- run the app with
LD_LIBRARY_PATH
set to point to your VLC lib dir - compile the application with
rpath
(some help) - use a packager like linuxdeployqt or similar to pre-bundle your app with all necessary libs
- move the libs to OS-wide directory, like
-
@metind said in shared lib problem for cross compile:
usr/include
As mentioned - this is not needed. At runtime, your app only needs the library, not headers.