Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. how to link with "so" files
Forum Updated to NodeBB v4.3 + New Features

how to link with "so" files

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 3 Posters 3.1k 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.
  • nishiokasN Offline
    nishiokasN Offline
    nishiokas
    wrote on last edited by nishiokas
    #1

    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 directory

    How can I use so-file without "(root)lib/" folder?
    Thanks.

    jsulmJ 1 Reply Last reply
    0
    • nishiokasN nishiokas

      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 directory

      How can I use so-file without "(root)lib/" folder?
      Thanks.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

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

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • nishiokasN Offline
        nishiokasN Offline
        nishiokas
        wrote on last edited by
        #3

        Thanks for your reply!

        Or are you talking about running your app?

        Yes.

        I wrote it ".pro" file and compile is okey.

        LIBS += -lz
        LIBS += -L"abc/lib" -labc
        LIBS += -L"/home/root/abc/lib" -labc
        

        But when the app start, it doesn't work.

        Thanks.

        jsulmJ 1 Reply Last reply
        0
        • nishiokasN nishiokas

          Thanks for your reply!

          Or are you talking about running your app?

          Yes.

          I wrote it ".pro" file and compile is okey.

          LIBS += -lz
          LIBS += -L"abc/lib" -labc
          LIBS += -L"/home/root/abc/lib" -labc
          

          But when the app start, it doesn't work.

          Thanks.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

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

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          JKSHJ 1 Reply Last reply
          0
          • jsulmJ jsulm

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

            JKSHJ Offline
            JKSHJ Offline
            JKSH
            Moderators
            wrote on last edited by JKSH
            #5

            @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 or patchelf to set your application's RUNPATH (or RPATH) to $ORIGIN if you want it to search its folder for libraries.

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            1 Reply Last reply
            3

            • Login

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