2 Replies
      Latest reply on Nov 12, 2019 1:32 AM by nianxuejie
      cjohnny Level 1 Level 1 (0 points)

        Following error message comes up when I try to create archive for macosx(mac catalyst),

        I'm using mac 10.15 and xcode 11 beta 7

         

        ld: in libname.a(test.o), building for Mac Catalyst, but linking in object file built for iOS Simulator, for architecture x86_64

        clang: error: linker command failed with exit code 1 (use -v to see invocation)

         

        I have built lib using clang -arch for amd64, arm64, x86, but for mac catalyst, since it's not really a new arch, I don't know

        what argument I should give to clang -arch

        • Re: how to compile/build mac catalyst lib using clang -arch
          pEpee Level 1 Level 1 (0 points)

          +1

          I get:

          ... Building for Mac Catalyst, but the linked library 'libcrypto.a' was built for macOS + iOS + iOS Simulator. You may need to restrict the platforms for which this library should be linked in the target editor, or replace it with an XCFramework that supports both platforms.

           

          As mentioned in the error, I _did_ build for macOS and iOS.

          ----

          Edit:

          Looks like a new target has been introduced for Mac CATALIST:

           

          CFLAG -target x86_64-apple-ios13.0-macabi.

          • Re: how to compile/build mac catalyst lib using clang -arch
            nianxuejie Level 1 Level 1 (0 points)

            +1

            ios libcurl compile script:

            function build_for_arch() {
              ARCH=$1
              HOST=$2
              SYSROOT=$3
              PREFIX=$4
              IPHONEOS_DEPLOYMENT_TARGET="8.0"
              export PATH="${DEVROOT}/usr/bin/:${PATH}"
              export CFLAGS="-arch ${ARCH} -pipe -Os -gdwarf-2 -isysroot ${SYSROOT} -miphoneos-version-min=${IPHONEOS_DEPLOYMENT_TARGET} -fembed-bitcode -Werror=partial-availability"
              export LDFLAGS="-arch ${ARCH} -isysroot ${SYSROOT}"
              ./configure --disable-shared --enable-ipv6 --enable-static ${SSL_FLAG} --enable-threaded-resolver --host="${HOST}" --prefix=${PREFIX} && make -j8 && make install
            }
            
            if [ "$1" == "openssl" ]
            then
              if [ ! -d ${HOME}/Desktop/openssl-ios-dist ]
              then
                echo "Please use https://github.com/sinofool/build-openssl-ios/ to build OpenSSL for iOS first"
                exit 8
              fi
              export SSL_FLAG=--with-ssl=${HOME}/Desktop/openssl-ios-dist
            else
              check_curl_ver
              export SSL_FLAG=--with-darwinssl
            fi
            
            #TMP_DIR=/tmp/build_libcurl_$$
            TMP_DIR=/Users/iqiyi/Desktop/code/curl/build
            
            build_for_arch arm64 arm-apple-darwin /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk ${TMP_DIR}/arm64 || exit 1
            build_for_arch armv7 armv7-apple-darwin /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk ${TMP_DIR}/armv7 || exit 3
            build_for_arch x86_64 x86_64-apple-darwin /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk ${TMP_DIR}/x86_64 || exit 4
            
            

             

             

            mac calalyst app link error:

             

            error: Building for Mac Catalyst, but the linked library 'libcurl_ios_arm_x86.a' was built for iOS + iOS Simulator.

             

            I donot know how to cross-compile the lib to support mac catalyst!!!

             

            Anyone can  help me?