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. @rpath issues with Qt 5.5/OSX in debug mode
QtWS25 Last Chance

@rpath issues with Qt 5.5/OSX in debug mode

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 2 Posters 3.3k 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.
  • A Offline
    A Offline
    Andy Edwards
    wrote on last edited by
    #1
    Qt Creator 3.5.1 (opensource)
    Based on Qt 5.5.1 (Clang 6.1 (Apple), 64 bit)
    
    Built on Oct 15 2015 01:54:05
    
    From revision b4c52505ca
    

    My app runs fine in Release mode. But when I try to debug it in Debug mode, I get the following dynamic linking error:

    Debugging starts
    dyld: Library not loaded: @rpath/QtCore.framework/Versions/5/QtCore
      Referenced from: /Users/andy/build-cavewhere-Desktop_Qt_5_5_1_clang_64bit-Debug/qtc_Desktop__e049b762-debug/install-root/Cavewhere.app/Contents/MacOS/Cavewhere
      Reason: image not found
    

    I dug around enough to figure out what @rpath is and see that in Qt 5.5, a change was made to use absolute rpath to Qt libraries for non-prefix builds.

    I also used otool -l | grep LC_RPATH to determine that no rpaths are getting inserted into my debug binary.

    Mystifyingly, the release binary doesn't have any LC_RPATH commands either and reports the same error when I try to run it from finder or the console -- yet when I run it from Qt, Qt seems to work some unknown magic to give it an rpath.

    Is this a Qt 5.5 bug?
    Does anyone know a workaround?

    I tried cloning my kit (Desktop Qt 5.5.1 clang 64bit) and adding the following to the platform linker flags: -rpath /Users/andy/Qt/5.5/clang_64/lib, but it didn't make any difference and I didn't find any LC_RPATH commands in binaries built with that kit either.

    1 Reply Last reply
    0
    • hskoglundH Offline
      hskoglundH Offline
      hskoglund
      wrote on last edited by
      #2

      Hi, normally with 5.5 you'll get an LC_RPATH inserted automagically by Qt Creator, both for release and debug builds. But it seems your project has a Qbs profile, maybe try rebuilding with a fresh profile?

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Andy Edwards
        wrote on last edited by
        #3

        @hskoglund Thanks for your response! It is a Qbs project, but how can I use a fresh profile? I don't see the option to create or select a different profile for a given kit in the Qbs section of the preferences.

        And how is it that Qt can run the release build even though the release build doesn't contain an LC_RPATH?

        1 Reply Last reply
        0
        • hskoglundH Offline
          hskoglundH Offline
          hskoglund
          wrote on last edited by
          #4

          Hi, re. starting afresh in Qbs, have to get back to you on that :-) I'm a Qbs noob

          Re. Qt Creator launching your app without any LC_RPATH, for example it can instead export the path using an environment variable, e.g.
          export DYLD_FRAMEWORK_PATH=/Users/andy/Qt/5.5/clang_64/lib

          A 1 Reply Last reply
          0
          • hskoglundH hskoglund

            Hi, re. starting afresh in Qbs, have to get back to you on that :-) I'm a Qbs noob

            Re. Qt Creator launching your app without any LC_RPATH, for example it can instead export the path using an environment variable, e.g.
            export DYLD_FRAMEWORK_PATH=/Users/andy/Qt/5.5/clang_64/lib

            A Offline
            A Offline
            Andy Edwards
            wrote on last edited by
            #5

            @hskoglund Qt seems to have automatically put a correct DYLD_FRAMEWORK_PATH in the build/run environment. Are you sure it would get used whenever the frameworks are linked with @rpath though?

            1 Reply Last reply
            0
            • hskoglundH Offline
              hskoglundH Offline
              hskoglund
              wrote on last edited by
              #6

              Hmm, normally Qt shouldn't mess with DYLD_FRAMEWORK_PATH but Qbs perhaps does it.
              When both @rpath and DYLD_FRAMEWORK_PATH are set, they are concatenated to each other in the list, i.e. when OSX loads frameworks it uses both of them.

              A 1 Reply Last reply
              0
              • hskoglundH hskoglund

                Hmm, normally Qt shouldn't mess with DYLD_FRAMEWORK_PATH but Qbs perhaps does it.
                When both @rpath and DYLD_FRAMEWORK_PATH are set, they are concatenated to each other in the list, i.e. when OSX loads frameworks it uses both of them.

                A Offline
                A Offline
                Andy Edwards
                wrote on last edited by
                #7

                @hskoglund are you sure the OSX loader can use the DYLD_FRAMEWORK_PATH in the @rpath list? The dyld man page indicates only one way to add something to the @rpath list -- LC_RPATH commands. It doesn't say anything about @rpath working with DYLD_FRAMEWORK_PATH.

                1 Reply Last reply
                0
                • hskoglundH Offline
                  hskoglundH Offline
                  hskoglund
                  wrote on last edited by
                  #8

                  I tested this way:

                  1. Made a copy of my Qt installation in /Users/henry/Qt to /Users/henry/QtCopy
                  2. Deleted the QtCore.framework directory from /Users/henry/Qt/5.5/clang64/lib
                  3. Tried to launch a Qt simple app. No good, error is: "dyld: Library not loaded: @rpath/QtCore.framework/Versions/5/QtCore"
                  4. Started a Terminal, typed:
                    export DYLD_FRAMEWORK_PATH=/Users/henry/QtCopy/5.5/clang64/lib
                  5. Tried to launch the same app. Works now. (Also checked with lsof -c appname that all of the framework DLLs are loaded from Qt but QtCore is loaded from QtCopy.)

                  Note that this DYLD_FRAMEWORK_PATH exporting stunt does not work for locating the platform plugin dll libqcocoa.dylib, Qt still looks for it in the usual places, i.e. the hardwired path in QtCore, a qt.conf file etc.

                  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