[Interest] Deploying Qt to macOS still...errr, sucks?

Jake Petroules Jake.Petroules at qt.io
Fri Nov 11 10:53:09 CET 2016


> On Nov 11, 2016, at 1:47 AM, Prashanth Udupa <prashanth.udupa at gmail.com> wrote:
> 
> Hi Jake,
>  
> > install_name_tool -id @executable_path/../Frameworks/externalLib.dylib MyWonderfulApp.app/Contents/Frameworks/externalLib.dylib
> 
> Don't do that last install_name_tool command. Instead, build your dynamic library with:
> in qmake...
>         QMAKE_SONAME_PREFIX = @rpath (which is equivalent to QMAKE_LFLAGS += -Wl,-install_name, at rpath/externalLib.dylib)
> or in qbs...
>         cpp.sonamePrefix: "@rpath"
> 
> In my case, I use an external-lib provided by someone else. I cannot rebuild it from source code - I can only link to it. Its available in /usr/local/lib folder on my Mac while building. But it needs to be included in the app-bundle for deployment.

In that case your install_name_tool command should be:

install_name_tool -id @rpath/externalLib.dylib /usr/local/lib/externalLib.dylib

Just run that once on your global copy and you don't need to run it again each time you build your app since it will work for copying to any application.

I'd also recommend reading up on Run-Path Dependent Libraries at Apple Developer: https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/RunpathDependentLibraries.html#//apple_ref/doc/uid/TP40008306-SW1 which explains the concept of relocatability in depth.

> 
> In anycase, I did not know about QMAKE_SONAME_PREFIX. This is good, thanks!
>  
> and build your main application and command line helper tool with:
> in qmake...
>         QMAKE_RPATHDIR += @loader_path/../Frameworks (which is equivalent to QMAKE_LFLAGS += -Wl,-rpath, at loader_path/../Frameworks)
> or in qbs...
>         cpp.rpaths: ["@loader_path/../Frameworks"]
> 
> I did not know this either. Thanks!
> 
> Thanks,
> Prashanth
> 

-- 
Jake Petroules - jake.petroules at qt.io
The Qt Company - Silicon Valley
Qbs build tool evangelist - qbs.io




More information about the Interest mailing list