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. How to set Lib(.so) path in such a way that exe should search for libs from the same folder where it is present?
Qt 6.11 is out! See what's new in the release blog

How to set Lib(.so) path in such a way that exe should search for libs from the same folder where it is present?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 1.8k Views
  • 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.
  • ashajgA Offline
    ashajgA Offline
    ashajg
    wrote on last edited by
    #1

    Hi guys

    I have written a code which needs some .so libs.
    My code is working perfectly on QT creator but when I am trying to run the same using the exe generated and required libs it is throwing this error

    error while loading shared labraries: libAECOSLib.so: cannot open shared object file: No such file or directory

    I tried couple of things like :

    QMAKE_LFLAGS += "-W1, -rpath,$$ORIGIN" in my pro file.
    but it is throwing error unrecognized command '-W1', '-rpath'

    I have included libs in this way :
    unix:!mac: LIBS += -L./IMI_Libraries/ -lARCOSLib

    when I am setting the path using terminal it is working

    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path to IMI Libraries

    But I want that it should be handled through pro file.

    How can I Solve this problem?

    Thanks
    Ashish

    jsulmJ 1 Reply Last reply
    0
    • ashajgA ashajg

      Hi guys

      I have written a code which needs some .so libs.
      My code is working perfectly on QT creator but when I am trying to run the same using the exe generated and required libs it is throwing this error

      error while loading shared labraries: libAECOSLib.so: cannot open shared object file: No such file or directory

      I tried couple of things like :

      QMAKE_LFLAGS += "-W1, -rpath,$$ORIGIN" in my pro file.
      but it is throwing error unrecognized command '-W1', '-rpath'

      I have included libs in this way :
      unix:!mac: LIBS += -L./IMI_Libraries/ -lARCOSLib

      when I am setting the path using terminal it is working

      export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path to IMI Libraries

      But I want that it should be handled through pro file.

      How can I Solve this problem?

      Thanks
      Ashish

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

      @ashajg said in How to set Lib(.so) path in such a way that exe should search for libs from the same folder where it is present?:

      How can I Solve this problem?

      You can write a shell script where you set LD_LIBRARY_PATH and then call your executable. Then use that script to start your app.

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

      1 Reply Last reply
      2
      • ashajgA Offline
        ashajgA Offline
        ashajg
        wrote on last edited by
        #3

        Hi @jsulm
        Thanks for the help !!!

        Is there any solution if I want to set this path in .pro file itself. I mean how can I make my executable to search for libs in the same folder by adding some paths in .pro file so that I can just run my executable on any system without using shell script or without setting LD_LIBRARY_PATH in terminal.

        jsulmJ 1 Reply Last reply
        0
        • ashajgA ashajg

          Hi @jsulm
          Thanks for the help !!!

          Is there any solution if I want to set this path in .pro file itself. I mean how can I make my executable to search for libs in the same folder by adding some paths in .pro file so that I can just run my executable on any system without using shell script or without setting LD_LIBRARY_PATH in terminal.

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

          @ashajg You can use https://doc.qt.io/qt-5/qmake-variable-reference.html#qmake-rpathdir

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

          ashajgA 1 Reply Last reply
          3
          • jsulmJ jsulm

            @ashajg You can use https://doc.qt.io/qt-5/qmake-variable-reference.html#qmake-rpathdir

            ashajgA Offline
            ashajgA Offline
            ashajg
            wrote on last edited by
            #5

            @jsulm Thank you !!!

            1 Reply Last reply
            0

            • Login

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