[Qbs] Building code generator and its dependencies for a different architecture than the rest of the products
Richard Weickelt
richard at weickelt.de
Fri Mar 20 17:56:34 CET 2020
> I think I almost got it to work. The problem I have now is that the app
> seems to link against the wrong version of the library:
>
> ld: warning: ignoring file
> /.../lib.eyJwcm9maWxlIjoiaG9zdFByb2ZpbGUifQ--.cd69e9f1/.tmp/lib, building
> for iOS-arm64 but attempting to link with file built for macOS-x86_64
> Project {
> Profile {
> name: "hostProfile"
> qbs.targetPlatform: "macos"
> }
>
> Profile {
> name: "targetProfile"
> baseProfile: project.profile
> }
>
> DynamicLibrary {
> name: "lib"
> files: ["lib.cpp"]
> multiplexByQbsProperties: ["profiles"]
>
> qbs.profiles: ["hostProfile", "targetProfile"]
>
> Depends { name: "cpp" }
> }
>
> CppApplication {
> consoleApplication: true
> name: "gen"
> files: ["gen.cpp"]
>
> qbs.profile: "hostProfile"
>
> Depends { name: "lib" }
> }
>
> CppApplication {
> name: "app"
> files: ["gen.cpp"]
>
> Depends { name: "lib" }
> }
> }
Looking at your project: Lib is multiplexed while app is not. Lib does not
have an aggregator. App does not constraint the dependency on lib.
In that case Qbs resoles the dependency as follows: app depends on all
variants of lib at the same time ("hostProfile" and "targetProfile"). I
think this could explain the error you are seeing and should be case 3b in
both, Qbs 1.15 and 1.16:
https://code.qt.io/cgit/qbs/qbs.git/tree/src/lib/corelib/language/moduleloader.cpp?h=1.15#n1108
https://code.qt.io/cgit/qbs/qbs.git/tree/src/lib/corelib/language/moduleloader.cpp?h=1.16#n1148
(Dependency matching will be a bit relaxed in Qbs 1.16, but it shouldn't
affect your case at all).
I think you should write:
CppApplication {
name: "app"
files: ["gen.cpp"]
Depends { name: "lib"; profiles: "targetProfile" }
}
to constraint the dependency (and make case 3c.).
Richard
More information about the Qbs
mailing list