Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. [Solved] How to make relative Qt library path in linux?
QtWS25 Last Chance

[Solved] How to make relative Qt library path in linux?

Scheduled Pinned Locked Moved Installation and Deployment
8 Posts 7 Posters 14.0k 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.
  • Z Offline
    Z Offline
    zither
    wrote on last edited by
    #1

    Dear all,

    In Windows deployment, place Qt lib files (*.dll) in same folder with .exe works fine.
    In Mac, we can make relative library address to executable binary files.

    ႈIn Linux, it needs to deploy library files (*.so) into /usr/lib/..
    Is there any methods, to place relative address from binary file to library files like in Windows?

    Thanks

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lgeyer
      wrote on last edited by
      #2

      "This":http://labs.qt.nokia.com/2011/10/28/rpath-and-runpath/ article might help you - and "RPATH":http://en.wikipedia.org/wiki/Rpath in general.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mkoskim
        wrote on last edited by
        #3

        [quote author="zither" date="1320502037"]Dear all,
        In Linux, it needs to deploy library files (*.so) into /usr/lib/..
        Is there any methods, to place relative address from binary file to library files like in Windows?[/quote]

        In Linux, libraries are searched from system directories and directories specified in LD_LIBRARY_PATH environment variable. For security reasons, Linux does not normally search libraries from user directories. You may modify it before loading your program - add "." to it, and libraries are searched from current working directory:

        @$ LD_LIBRARY_PATH=. ./myProgram@

        If you want to make a program that does it automatically, start your program from script, or write a program to modify the variable and then launch the actual program.

        http://mkoskim.wordpress.com
        http://mkoskim.drivehq.com
        http://mkoskim.deviantart.com

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dangelog
          wrote on last edited by
          #4

          See also http://doc.qt.nokia.com/4.7/deployment-x11.html#creating-the-application-package

          Software Engineer
          KDAB (UK) Ltd., a KDAB Group company

          1 Reply Last reply
          0
          • B Offline
            B Offline
            baysmith
            wrote on last edited by
            #5

            Use $ORIGIN in the executable's rpath. For example, add the following to your qmake project file.
            @
            unix:!mac{
            QMAKE_LFLAGS += -Wl,--rpath=\$$ORIGIN
            QMAKE_RPATH=
            }
            @
            Setting the QMAKE_RPATH clears the default rpath setting for the Qt libraries. This allows for bundling the Qt libraries with the application. If you want the rpath to include the path to the Qt libraries, don’t set QMAKE_RPATH.

            Nokia Certified Qt Specialist.

            1 Reply Last reply
            0
            • Z Offline
              Z Offline
              zither
              wrote on last edited by
              #6

              The way I want is to make relative address to application without effecting system variables.

              I solve the problem with @Bradley said.

              Thanks to all

              1 Reply Last reply
              0
              • B Offline
                B Offline
                BorisSclauzero
                wrote on last edited by
                #7

                Hi zither,

                [quote author="zither" date="1320502037"]In Mac, we can make relative library address to executable binary files.[/quote]

                Can you explain me how to do this?
                It's about two days that I am stuck with this problem.

                Thanks in advance
                Boris

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Hi,

                  Please don't revive old thread that are almost 3 years old.

                  That said, have a look at the install_name_tool command. It's what is used on OS X (and e.g. macdeployqt)

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  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