Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Don't see library in iOS device but on iOS emulator all is OK. Why?



  • Hello all!

    I have static library (.a) and dynamic library (.dylib) that is attached to my project. Everything working while I am using iOS emulator. But when I am trying to use real device it's failing:

    warning: ignoring file /Users/alexandr/Projects/study/qt/plainc_libzip/plainc_libzip/libs/libzip/libzipstatic.a, file was built for archive which is not the architecture being linked (arm64): /Users/alexandr/Projects/study/qt/plainc_libzip/plainc_libzip/libs/libzip/libzipstatic.a
    

    Whole compile log:

    Ld Release-iphoneos/plainc_libzip.app/plainc_libzip normal arm64
        cd /Users/alexandr/Projects/study/qt/plainc_libzip/build-plainc_libzip-Qt_5_12_1_for_iOS-Release
        export IPHONEOS_DEPLOYMENT_TARGET=11.0
        export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Users/alexandr/Applications/Qt5.12/5.12.1/ios/bin:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.1.sdk -L/Users/alexandr/Projects/study/qt/plainc_libzip/build-plainc_libzip-Qt_5_12_1_for_iOS-Release/Release-iphoneos -L/Users/alexandr/Projects/study/qt/plainc_libzip/plainc_libzip/libs/libzip -L/Users/alexandr/Applications/Qt5.12/5.12.1/ios/plugins/platforms -L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.1.sdk/System/Library/Frameworks -L/Users/alexandr/Applications/Qt5.12/5.12.1/ios/lib -L/Users/alexandr/Applications/Qt5.12/5.12.1/ios/plugins/imageformats -L/Users/alexandr/Applications/Qt5.12/5.12.1/ios/plugins/qmltooling -L/Users/alexandr/Applications/Qt5.12/5.12.1/ios/plugins/bearer -L/Users/alexandr/Applications/Qt5.12/5.12.1/ios/qml/QtQuick.2 -L/Users/alexandr/Applications/Qt5.12/5.12.1/ios/qml/QtQuick/Window.2 -F/Users/alexandr/Projects/study/qt/plainc_libzip/build-plainc_libzip-Qt_5_12_1_for_iOS-Release/Release-iphoneos -filelist /Users/alexandr/Projects/study/qt/plainc_libzip/build-plainc_libzip-Qt_5_12_1_for_iOS-Release/.xcode/plainc_libzip.build/Release-iphoneos/plainc_libzip.build/Objects-normal/arm64/plainc_libzip.LinkFileList -miphoneos-version-min=11.0 -dead_strip -Xlinker -object_path_lto -Xlinker /Users/alexandr/Projects/study/qt/plainc_libzip/build-plainc_libzip-Qt_5_12_1_for_iOS-Release/.xcode/plainc_libzip.build/Release-iphoneos/plainc_libzip.build/Objects-normal/arm64/plainc_libzip_lto.o -fembed-bitcode-marker -stdlib=libc++ -Wl,-e,_qt_main_wrapper -Wl,-rpath,@executable_path/Frameworks -lz.1 -L/Users/alexandr/Projects/study/qt/plainc_libzip/plainc_libzip/libs/libzip/ -L/Users/alexandr/Applications/Qt5.12/5.12.1/ios/plugins/platforms -framework UIKit -framework AssetsLibrary -L/Users/alexandr/Applications/Qt5.12/5.12.1/ios/lib -framework MobileCoreServices -framework OpenGLES -L/Users/alexandr/Applications/Qt5.12/5.12.1/ios/plugins/imageformats -L/Users/alexandr/Applications/Qt5.12/5.12.1/ios/plugins/qmltooling -L/Users/alexandr/Applications/Qt5.12/5.12.1/ios/plugins/bearer -L/Users/alexandr/Applications/Qt5.12/5.12.1/ios/qml/QtQuick.2 -L/Users/alexandr/Applications/Qt5.12/5.12.1/ios/qml/QtQuick/Window.2 -lm -lzipstatic -framework Foundation -framework QuartzCore -framework AudioToolbox -framework CoreFoundation -framework CoreGraphics -framework CoreText -framework ImageIO -lqios -lQt5FontDatabaseSupport -lqtfreetype -lQt5GraphicsSupport -lQt5ClipboardSupport -lqgif -lqicns -lqico -lqjpeg -lqmacheif -lqmacjp2 -lqtga -lqtiff -lqwbmp -lqwebp -lqmldbg_debugger -framework Security -lqmldbg_inspector -lqmldbg_local -lqmldbg_messages -lqmldbg_native -lqmldbg_nativedebugger -lqmldbg_preview -lqmldbg_profiler -lqmldbg_quickprofiler -lqmldbg_server -lQt5PacketProtocol -lqmldbg_tcp -lqgenericbearer -lqtquick2plugin -lwindowplugin -lQt5Quick -lQt5Qml -lQt5Gui -lqtlibpng -lqtharfbuzz -lQt5Network -lQt5Core -lqtpcre2 -Xlinker -dependency_info -Xlinker /Users/alexandr/Projects/study/qt/plainc_libzip/build-plainc_libzip-Qt_5_12_1_for_iOS-Release/.xcode/plainc_libzip.build/Release-iphoneos/plainc_libzip.build/Objects-normal/arm64/plainc_libzip_dependency_info.dat -o /Users/alexandr/Projects/study/qt/plainc_libzip/build-plainc_libzip-Qt_5_12_1_for_iOS-Release/Release-iphoneos/plainc_libzip.app/plainc_libzip
    ld: warning: ignoring file /Users/alexandr/Projects/study/qt/plainc_libzip/plainc_libzip/libs/libzip/libzipstatic.a, file was built for archive which is not the architecture being linked (arm64): /Users/alexandr/Projects/study/qt/plainc_libzip/plainc_libzip/libs/libzip/libzipstatic.a
    Undefined symbols for architecture arm64:
      "_zip_open", referenced from:
          _main in main.o
    ld: symbol(s) not found for architecture arm64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    
    ** BUILD FAILED **
    
    
    The following build commands failed:
    	Ld Release-iphoneos/plainc_libzip.app/plainc_libzip normal arm64
    (1 failure)
    make: *** [xcodebuild-release-device] Error 65
    15:00:02: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project plainc_libzip (kit: Qt 5.12.1 for iOS)
    When executing step "Make"
    

    What am I missing?

    My *.pro file is:

    QT += quick
    CONFIG += c++11
    
    # The following define makes your compiler emit warnings if you use
    # any Qt feature that has been marked deprecated (the exact warnings
    # depend on your compiler). Refer to the documentation for the
    # deprecated API to know how to port your code away from it.
    DEFINES += QT_DEPRECATED_WARNINGS
    
    # You can also make your code fail to compile if it uses deprecated APIs.
    # In order to do so, uncomment the following line.
    # You can also select to disable deprecated APIs only up to a certain version of Qt.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    
    SOURCES += \
            main.cpp
    
    RESOURCES += qml.qrc
    
    # Additional import path used to resolve QML modules in Qt Creator's code model
    QML_IMPORT_PATH =
    
    # Additional import path used to resolve QML modules just for Qt Quick Designer
    QML_DESIGNER_IMPORT_PATH =
    
    # Default rules for deployment.
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target
    
    HEADERS += \
    libs/libzip/config.h \
    libs/libzip/zip.h \
    libs/libzip/zipconf.h
    
    macx {
    
    LIBS += -lz.1
    LIBS += -L$$PWD/libs/libzip/ -lzipstatic
    
    INCLUDEPATH += $$PWD/libs/libzip
    DEPENDPATH += $$PWD/libs/libzip
    
    PRE_TARGETDEPS += $$PWD/libs/libzip/libzipstatic.a
    
    }
    
    ios {
    
    LIBS += -lz.1
    LIBS += -L$$PWD/libs/libzip/ -lzipstatic
    
    INCLUDEPATH += $$PWD/libs/libzip
    DEPENDPATH += $$PWD/libs/libzip
    
    PRE_TARGETDEPS += $$PWD/libs/libzip/libzipstatic.a
    
    }
    

  • Moderators

    hi @bogong
    the iPhone Emulator uses a different, incompatible, compiler compared to actual iOS devices.

    Thats because the the Emulator runs on the Intel CPU/Architectur, where as iPhone use ARM(IIRC)

    you need to compile your libs for that processor to use it for actual devices.



  • @J.Hilk Already found it. Thanks. I found this iOS toolchain for CMake to build for Arm64.

    Is it OK?


  • Moderators

    @bogong
    possible, I don't use make and usually build my libs together with my project in one go :)



  • Solution found. It's a little hard coded solution but it works for me and my own purpose.
    How-to published in Github


Log in to reply