Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. shared lib problem for cross compile
Forum Updated to NodeBB v4.3 + New Features

shared lib problem for cross compile

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 2 Posters 757 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    metind
    wrote on 6 Aug 2020, 11:11 last edited by
    #1

    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

    S 1 Reply Last reply 6 Aug 2020, 11:22
    0
    • M metind
      6 Aug 2020, 11:11

      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

      S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 6 Aug 2020, 11:22 last edited by
      #2

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

      (Z(:^

      M 1 Reply Last reply 6 Aug 2020, 11:36
      0
      • S sierdzio
        6 Aug 2020, 11:22

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

        M Offline
        M Offline
        metind
        wrote on 6 Aug 2020, 11:36 last edited by
        #3

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

        S 1 Reply Last reply 6 Aug 2020, 11:42
        0
        • M metind
          6 Aug 2020, 11:36

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

          S Offline
          S Offline
          sierdzio
          Moderators
          wrote on 6 Aug 2020, 11:42 last edited by
          #4

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

          (Z(:^

          M 1 Reply Last reply 6 Aug 2020, 11:47
          1
          • S sierdzio
            6 Aug 2020, 11:42

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

            M Offline
            M Offline
            metind
            wrote on 6 Aug 2020, 11:47 last edited by
            #5

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

            1 Reply Last reply
            0
            • S Offline
              S Offline
              sierdzio
              Moderators
              wrote on 6 Aug 2020, 11:51 last edited by
              #6

              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.

              (Z(:^

              M 1 Reply Last reply 6 Aug 2020, 12:05
              0
              • S sierdzio
                6 Aug 2020, 11:51

                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.

                M Offline
                M Offline
                metind
                wrote on 6 Aug 2020, 12:05 last edited by
                #7

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

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  sierdzio
                  Moderators
                  wrote on 6 Aug 2020, 12:10 last edited by
                  #8

                  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

                  (Z(:^

                  M 1 Reply Last reply 6 Aug 2020, 12:31
                  2
                  • S sierdzio
                    6 Aug 2020, 12:10

                    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
                    M Offline
                    M Offline
                    metind
                    wrote on 6 Aug 2020, 12:31 last edited by
                    #9

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

                    S 1 Reply Last reply 6 Aug 2020, 12:34
                    0
                    • M metind
                      6 Aug 2020, 12:31

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

                      S Offline
                      S Offline
                      sierdzio
                      Moderators
                      wrote on 6 Aug 2020, 12:34 last edited by
                      #10

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

                      (Z(:^

                      1 Reply Last reply
                      0

                      1/10

                      6 Aug 2020, 11:11

                      • Login

                      • Login or register to search.
                      1 out of 10
                      • First post
                        1/10
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved