Linking to static libraries with correct architecture when building in xcode



  • I have a QMake .pri file with something like this:

    LIBS += \
            -L$$PWD/sdk/libs/ios/arm64 -laid \
            -L$$PWD/sdk/libs/ios/arm64 -lapp \
            -L$$PWD/sdk/libs/ios/armv7 -laid \
            -L$$PWD/sdk/libs/ios/armv7 -lapp
    

    The libs are static libraries (aid.a, app.a). When I use QtCreator to compile the project (and deploy on ios) using xcode - I get linker errors if both LIBS are linked but it compiles and deploy fine if I take one of the architectures out and use QMAKE_IOS_DEVICE_ARCHS = armv7:

    QMAKE_IOS_DEVICE_ARCHS = armv7
    
    LIBS += \
            -L$$PWD/sdk/libs/ios/armv7 -laid \
            -L$$PWD/sdk/libs/ios/armv7 -lapp
    

    But I'll really like to be able to build for both architectures in one go - so I don't end up having to maintain two builds in the app store? Is this possible?


  • Qt Champions 2018

    @Larpon Check QMake documentation: http://doc.qt.io/qt-5/qmake-variable-reference.html
    It is done like this:

    unix:LIBS += -L/usr/local/lib -lmath
    win32:LIBS += c:/mylibs/math.lib
    


  • @jsulm thanks - I've seen that syntax before but how do I set it for eg. both ios armv7 and arm64?

    I can't find a list of ios specifics anywhere?

    It should maybe be something like:

    ios-armv7:LIBS += -L... -l...
    ios-arm64:LIBS += -L... -l...
    

    But these don't exist AFAIK?
    xcode is building multiple architectures but I can't find a way to include my static libs to each architecture - a solution within xcode would be ok I guess


  • Lifetime Qt Champion

    Hi,

    AFAIK, the standard way to do that on macOS (but is also valid for iOS) is to assemble your different libraries builds into only one that is multi arch and then link your application to it.



  • @SGaist - cool thanks. So I should be able to do this to them? And link new.a yeah?


  • Lifetime Qt Champion

    Yes, exactly



  • @SGaist Thank you very much!

    I haven't got around to test it properly yet - but I'm marking this as solved.