[Development] Qt 4.x and Qt 5 frameworks should use @rpath (QTBUG-31814)

Adam Strzelecki ono at java.pl
Fri Aug 8 09:30:26 CEST 2014


> How does a launched application find the Qt frameworks that were installed by 
> the SDK? And how do those frameworks find the plugins?

"Phase I" changes does not change workflow, so all apps built with Qt find Qt libraries as before. Since all Qt libraries are now using @rpath id prefix they will be referenced w/o absolute (real) paths:

$ otool -L qtbase/bin/qdoc
qtbase/bin/qdoc:
	@rpath/QtXml.framework/Versions/5/QtXml (compatibility version 5.4.0, current version 5.4.0)
	@rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.4.0, current version 5.4.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)

While binary itself is built with -Wl,-rpath,<QT_LIBS_PATH>.

$ otool -l /tmp/test | grep -A 2 LC_RPATH
          cmd LC_RPATH
      cmdsize 40
         path /Applications/Qt/5.4/clang_64/lib (offset 12)

NOTE: Qt SDK internal tools binaries carry relative paths to libraries, while user built binaries have full path to Qt in rpath, i.e.:

$ otool -l qtbase/bin/qdoc | grep -A 2 LC_RPATH
          cmd LC_RPATH
      cmdsize 40
         path @executable_path/../lib (offset 12)

> Doesn't DYLD_LIBRARY_PATH and 
> DYLD_FRAMEWORK_PATH need to be set? Is the Creator modification one of those 
> changes?

None of these needed. There are no workflow changes. Built binary still holds path to Qt, however none of the Qt frameworks have any absolute paths embedded anymore, therefore we don't need to touch (rewrite) Qt libraries anymore.

During deployment macdeployqt is about replace LC_RPATH pointing to absolute Qt libraries path with @executable_path/../Frameworks, since libraries will be copied into Frameworks bundle folder.

> Also, how does QtCore find the plugins on behalf of every library? For example, 
> when QtGui requests the cocoa platform plugin, what is the search logic?

Nothing has changed. It works like before.

Regards,
-- 
Adam


More information about the Development mailing list