Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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


  • Moderators

    @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.



  • @sierdzio thanks your reply. Capture.PNG
    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. I couldn't find any way how can I define lib and includepath at host part and can work at client side.

    Best regards,


  • Moderators

    @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 about LIBS.

    I couldn't find any way how can I define lib and includepath at host part and can work at client side.



  • @sierdzio Got it and gave another error. Think cant find lib files... Capture.PNG


  • Moderators

    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.



  • @sierdzio picture shows where is the related files at pi4 and when run ldd gives these errors. 1.jpeg 2.jpeg


  • Moderators

    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


  • @sierdzio Thanks for your help. I only copied the lib and include directory to usr/lib and usr/include then at ubuntu part sync the sysroot with rsync, defined libs as LIBS+=-lyourLibName and worked.


  • Moderators

    @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.


Log in to reply