[Qbs] darwin - Installing DynamicLibrary (Framework) dependencies on the resulting bundle

Jake Petroules Jake.Petroules at qt.io
Mon Oct 23 18:39:33 CEST 2017


For now you can work around the issue by installing the shared library to a location within your app bundle. You can install a framework by putting this inside the DynamicLibrary block:

Group {
    fileTagsFilter: ["bundle.content"]
    qbs.install: true
    qbs.installDir: "MyApp.app/Contents/Frameworks"
    qbs.installSourceBase: product.buildDirectory
}

However if you're writing multiple plugins that all depend on the same shared library that's where it gets a little tricky.

I think you're installing your software as a series of plugins that get placed at $HOME/Library/Plug-Ins, right? If so, then:

Group {
    fileTagsFilter: ["bundle.content"]
    qbs.install: true
    qbs.installDir: "Library/Frameworks"
    qbs.installSourceBase: product.buildDirectory
}

should be sufficient. You'll also likely want to set cpp.sonamePrefix: "@rpath" on your shared framework, and then something like cpp.rpaths: ["@loader_path/../../../Frameworks"] on your plugins (exact number of ../ will vary depending on your install layout).

Do I understand correctly that this is about your audio plugins project? If so, a listing of all the file paths that your installer currently creates on the system when your product is installed, would be helpful in terms of giving recommendations. For example, something like:

$HOME/Library/PlugIns/XYZ.bundle/Contents/Info.plist
$HOME/Library/PlugIns/XYZ.bundle/Contents/MacOS/XYZ
$HOME/Library/PlugIns/XYZ.bundle/Contents/Resources/blah
$HOME/Library/PlugIns/Other.bundle/Contents/Info.plist
$HOME/Library/PlugIns/Other.bundle/Contents/MacOS/Other
$HOME/Library/PlugIns/Other.bundle/Contents/Resources/blah
...

> On Oct 23, 2017, at 1:07 AM, Nuno Santos <nunosantos at imaginando.pt> wrote:
> 
> Jake,
> 
> Thanks for your reply.
> 
> So… what are my options then? Can I link the libraries without being Frameworks, have them installed to my product output dir and link them and use them with my application?
> 
> While I have already managed to create a lib from my shared resources, which depends on other libs, I still couldn’t use this shared lib in a small test project. It always fails when running because it can’t find the libraries. Yesterday I have also tried to make them static libraries without success.
> 
> So far I was trying to setup this libs as DynamicLibrary with as a bundle. I have now removed the bundle dependency and property but it also didn’t worked.
> 
> This is what I have at the moment:
> 
> // workspace/qbs-app-test/qbs-app-tes.qbs - generated by QtCreator
> 
> import qbs
> 
> Project {
>    references: ["../shared/shared.qbs"]
>    minimumQbsVersion: "1.7.1"
> 
>    CppApplication {
>        Depends { name: "Qt.core" }
>        Depends { name: "Qt.quick" }
>        Depends { name: "shared” } // << this is my shared library dependency
>        property pathList qmlImportPaths: []
>        cpp.cxxLanguageVersion: "c++11"
> 
>        cpp.defines: ["QT_DEPRECATED_WARNINGS"]
> 
>        files: ["main.cpp", "qml.qrc"]
> 
>        Group {
>            fileTagsFilter: product.type
>            qbs.install: true
>            qbs.installSourceBase: product.buildDirectory
>        }
>    }
> }
> 
> // workspace/shared/shared.qbs
> 
> import qbs
> 
> Project {
>    name: "shared"
>    references: [
>        "external/3rd-party-lib-1/3rd-party-lib-1.qbs",
>        "external/3rd-party-lib-2/3rd-party-lib-2.qbs"
>    ]
> 
>    DynamicLibrary {
>        Depends { name: "cpp" }
>        cpp.includePaths: [".", "external/", "external/3rd-party-lib-1", "external/3rd-party-lib-2"]
>        cpp.frameworks: ["CoreFoundation", "AppKit", "IOKit"]
>        Depends { name: "parseqt" }
>        Depends { name: "dsp" }
>        Depends { name: "Qt"; submodules: ["core", "gui", "qml", "network", "quick"] }
>        files: [...]
> 
>        Export {
>           Depends { name: "cpp" }
>           cpp.includePaths: [product.sourceDirectory]
>        }
>    }
> }
> 
> 
> When I run the project right now this is what happens:
> 
> dyld: Library not loaded: 3rd-party-lib-1.framework/Versions/A/3rd-party-lib-1
>  Referenced from: /Users/nsantos/workspace/build-qbs-app-test-Desktop_Qt_5_7_1_clang_64bit2-Debug/qtc_Desktop_Qt_5_7_1_clang_64bit2_Debug/install-root/Library/Frameworks/shared.framework/Versions/A/shared
>  Reason: image not found
> The program has unexpectedly finished.
> 
> 
> What am I missing here?
> 
> Thanks!
> 
> Regards,
> 
> Nuno
> 
>> On 23 Oct 2017, at 01:43, Jake Petroules <Jake.Petroules at qt.io> wrote:
>> 
>> Yes, framework embedding is not yet supported, although this is a high priority item for a future release. It may not make THE next release in part because we want to make sure the solution is general enough to be applicable to other platforms as well, such as embedding libraries into Android APKs.
>> 
>>> On Oct 22, 2017, at 3:17 PM, Nuno Santos <nunosantos at imaginando.pt> wrote:
>>> 
>>> Hi,
>>> 
>>> I’m trying to a application project depend on custom set of libraries. The libraries are referenced on the project and marked as dependencies. The project builds but crashes on launch because the dependencies are not copied as frameworks to the resulting bundle. Is this a limitation of qbs at the moment? 	
>>> 
>>> qbs 1.9.1 / Qt 5.7.1 / Mac OSX 
>>> 
>>> Thx
>>> 
>>> Regards,
>>> 
>>> Nuno
>>> _______________________________________________
>>> Qbs mailing list
>>> Qbs at qt-project.org
>>> http://lists.qt-project.org/mailman/listinfo/qbs
>> 
>> -- 
>> Jake Petroules - jake.petroules at qt.io
>> The Qt Company - Silicon Valley
>> Qbs build tool evangelist - qbs.io
>> 
> 

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



More information about the Qbs mailing list