Xcode6.1编译64位平台OpenSSL和CURL

Home / iOS MrLee 2016-4-20 4660

这是国外找到的一篇文章,我英文翻译一般,自己看看还行。简单说下操作
我后面又重新写了一篇文章,请参考:XCode7.2.1下面编译curl脚本
首先下载源码,下面文章有官方下载地址(本站已经下载好了),然后创建一个.sh的脚本(类似windows的bat文件),再把下面的脚本内容复制进去,然后稍微个性下版本号,例如我是xcode7.1,那么对应的iOS是9.2,我的修改如下:
OPENSSL_VERSION="1.0.1s"
 
DEVELOPER="/Applications/Xcode.app/Contents/Developer"
 
SDK_VERSION="9.2"
MIN_VERSION="9.2"

然后把这个文件授权 chmod 777 xxx.sh,然后打开终端,把这个文件拖放进来回车就可以生成了。
原文如下:

Building OpenSSL and CURL for iOS 64-bit platform

We provide here instructions to build OpenSSL and CURL third party libraries to work with RMSDK 10 and RMSDK 11.Note that CURL library used in RMSDK 11 needs to be compiled with SSL option. For RMSDK 10, it is optional. The build flag in the script below uses without-ssl for RMSDK 10. The flag to build for SSL is with-darwinssl.For customers who are accustomed to using the make file DLBuildIOSExternals.mak, to build both OpenSSL and CURL, please note that the new scripts replace this makefile.System requirements:
  • Xcode 6.1.1
  • iOS SDK 8.1
  • OpenSSL 1.0.1j or newer (tested with 1.0.1j, for newer, modify the script)
  • CURL 7.36.0 (for different version, modify the build script)
The scripts are pasted as text in this solution. A copy of the scripts are posted here for download (check back later if the links are not working yet).

Building OpenSSL

The script is used to build OpenSSL for iOS using an Apple MacBookPro running Mac OS 10.9.5, with XCode 6.1.1 with iOS 8.1 SDK.
  1. Obtain the source if needed. Select "openssl-1.0.1j.tar.gz" and save the tar file to a folder. The build script will extract the archive. openssl:本站下载
  2. Set up build.sh in the same folder as the tar file. Copy and paste the script text below to this build.sh file, or use the downloaded version. The .sh file name does not have to be precisely called "build."
  3. Build OpenSSL. Run build.sh script from command line from a terminal window on Mac, and it will create include and lib folder with appropriate contents.
  4. To book2png, as part of the RMSDK build, copy the include and lib folders to thirdparty\openssl\public\ios directory in the RMSDK source tree. You may have to modify the path and the file names for the newly built OpenSSL in your own reader app project.
  5. Continue with building RMSDK from this point on.
    #!/bin/bash
    #This script builds a static version of
    # OpenSSL ${OPENSSL_VERSION} for iOS 7.1 that contains code for
    # arm64, armv7, arm7s, i386 and x86_64.
    set -x
    # Setup paths to stuff we need
    OPENSSL_VERSION="1.0.1j"
    DEVELOPER="/Applications/Xcode.app/Contents/Developer"
    SDK_VERSION="8.1"
    MIN_VERSION="8.1"
    IPHONEOS_PLATFORM="${DEVELOPER}/Platforms/iPhoneOS.platform"
    IPHONEOS_SDK="${IPHONEOS_PLATFORM}/Developer/SDKs/iPhoneOS${SDK_VERSION}.sdk"
    IPHONEOS_GCC="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
    IPHONESIMULATOR_PLATFORM="${DEVELOPER}/Platforms/iPhoneSimulator.platform"
    IPHONESIMULATOR_SDK="${IPHONESIMULATOR_PLATFORM}/Developer/SDKs/iPhoneSimulator${SDK_VERSION}.sdk"
    IPHONESIMULATOR_GCC="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
    # Make sure things actually exist
    if [ ! -d "$IPHONEOS_PLATFORM" ]; then
     echo "Cannot find $IPHONEOS_PLATFORM"
     exit 1
    fi
    if [ ! -d "$IPHONEOS_SDK" ]; then
     echo "Cannot find $IPHONEOS_SDK"
     exit 1
    fi
    if [ ! -x "$IPHONEOS_GCC" ]; then
     echo "Cannot find $IPHONEOS_GCC"
     exit 1
    fi
    if [ ! -d "$IPHONESIMULATOR_PLATFORM" ]; then
     echo "Cannot find $IPHONESIMULATOR_PLATFORM"
     exit 1
    fi
    if [ ! -d "$IPHONESIMULATOR_SDK" ]; then
     echo "Cannot find $IPHONESIMULATOR_SDK"
     exit 1
    fi
    if [ ! -x "$IPHONESIMULATOR_GCC" ]; then
     echo "Cannot find $IPHONESIMULATOR_GCC"
     exit 1
     fi
    # Clean up whatever was left from our previous build
    rm -rf include lib
    rm -rf /tmp/openssl-${OPENSSL_VERSION}-*
    rm -rf /tmp/openssl-${OPENSSL_VERSION}-*.*-log
    build()
    {
       TARGET=$1
        ARCH=$2
        GCC=$3
        SDK=$4
        EXTRA=$5
        rm -rf "openssl-${OPENSSL_VERSION}"
        tar xfz "openssl-${OPENSSL_VERSION}.tar.gz"
        pushd .
        cd "openssl-${OPENSSL_VERSION}"
        /Configure ${TARGET} --openssldir="/tmp/openssl-${OPENSSL_VERSION}-${ARCH}" ${EXTRA} &> "/tmp/openssl-${OPENSSL_VERSION}-${ARCH}.log"
        perl -i -pe 's|static volatile sig_atomic_t intr_signal|static volatile int intr_signal|' crypto/ui/ui_openssl.c
        perl -i -pe "s|^CC= gcc|CC= ${GCC} -arch ${ARCH} -miphoneos-version-min=${MIN_VERSION}|g" Makefile
       perl -i -pe "s|^CFLAG= (.*)|CFLAG= -isysroot ${SDK} \$1|g" Makefile
       make &> "/tmp/openssl-${OPENSSL_VERSION}-${ARCH}.build-log"
       make install &> "/tmp/openssl-${OPENSSL_VERSION}-${ARCH}.install-log"
       popd
       rm -rf "openssl-${OPENSSL_VERSION}"
    }
    build "BSD-generic32" "armv7" "${IPHONEOS_GCC}" "${IPHONEOS_SDK}" ""
    build "BSD-generic32" "armv7s" "${IPHONEOS_GCC}" "${IPHONEOS_SDK}" ""
    build "BSD-generic64" "arm64" "${IPHONEOS_GCC}" "${IPHONEOS_SDK}" ""
    build "BSD-generic32" "i386" "${IPHONESIMULATOR_GCC}" "${IPHONESIMULATOR_SDK}" ""
    build "BSD-generic64" "x86_64" "${IPHONESIMULATOR_GCC}" "${IPHONESIMULATOR_SDK}" "-DOPENSSL_NO_ASM"
    #
    mkdir include
    cp -r /tmp/openssl-${OPENSSL_VERSION}-i386/include/openssl include/
    mkdir lib
    lipo \
    "/tmp/openssl-${OPENSSL_VERSION}-armv7/lib/libcrypto.a" \
    "/tmp/openssl-${OPENSSL_VERSION}-armv7s/lib/libcrypto.a" \
    "/tmp/openssl-${OPENSSL_VERSION}-arm64/lib/libcrypto.a" \
    "/tmp/openssl-${OPENSSL_VERSION}-i386/lib/libcrypto.a" \
    "/tmp/openssl-${OPENSSL_VERSION}-x86_64/lib/libcrypto.a" \
    -create -output lib/libcrypto.a
    lipo \
    "/tmp/openssl-${OPENSSL_VERSION}-armv7/lib/libssl.a" \
    "/tmp/openssl-${OPENSSL_VERSION}-armv7s/lib/libssl.a" \
    "/tmp/openssl-${OPENSSL_VERSION}-arm64/lib/libssl.a" \
    "/tmp/openssl-${OPENSSL_VERSION}-i386/lib/libssl.a" \
    "/tmp/openssl-${OPENSSL_VERSION}-x86_64/lib/libssl.a" \
    -create -output lib/libssl.a
    rm -rf "/tmp/openssl-${OPENSSL_VERSION}-*"
    rm -rf "/tmp/openssl-${OPENSSL_VERSION}-*.*-log"
    

     

    Building libcurl

    1. Obtain the source if needed. Save "curl-7.36.0.zip" to a folder.  curl:本站下载
    2. Set up build.sh in the same folder as the tar file. Copy and paste the script text below to this build.sh file, or, use the downloaded version. The .sh file name does not have to be called "build."
    3. Build CURL. Run the build.sh script from command line from a terminal window on Mac, and it will include-32, include-64 and lib folder with appropriate contents.
    4. For the RMSDK build, to build book2png, copy include-32, include-64 and lib folders to thirdparty\curl\public\ios directory in the RMSDK source tree. You may have to modify the path and the file names for the newly built CURL libraries in your own reader app project.
    5. Continue with building RMSDK from this point on.
      #!/bin/bash
      # This script builds a static version of
      # curl ${CURL_VERSION} for iOS 7.1 that contains code for
      # arm64, armv7, arm7s, i386 and x86_64.
      set -x
      # Setup paths to stuff we need
      CURL_VERSION="7.36.0"
      DEVELOPER="/Applications/Xcode.app/Contents/Developer"
      SDK_VERSION="8.1"
      MIN_VERSION="8.1"
      IPHONEOS_PLATFORM="${DEVELOPER}/Platforms/iPhoneOS.platform"
      IPHONEOS_SDK="${IPHONEOS_PLATFORM}/Developer/SDKs/iPhoneOS${SDK_VERSION}.sdk"
      IPHONEOS_GCC="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
      IPHONESIMULATOR_PLATFORM="${DEVELOPER}/Platforms/iPhoneSimulator.platform"
      IPHONESIMULATOR_SDK="${IPHONESIMULATOR_PLATFORM}/Developer/SDKs/iPhoneSimulator${SDK_VERSION}.sdk"
      IPHONESIMULATOR_GCC="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
      # Make sure things actually exist
      if [ ! -d "$IPHONEOS_PLATFORM" ]; then
       echo "Cannot find $IPHONEOS_PLATFORM"
       exit 1
      fi
      if [ ! -d "$IPHONEOS_SDK" ]; then
       echo "Cannot find $IPHONEOS_SDK"
       exit 1
      fi
      if [ ! -x "$IPHONEOS_GCC" ]; then
       echo "Cannot find $IPHONEOS_GCC"
       exit 1
      fi
      if [ ! -d "$IPHONESIMULATOR_PLATFORM" ]; then
       echo "Cannot find $IPHONESIMULATOR_PLATFORM"
       exit 1
      fi
      if [ ! -d "$IPHONESIMULATOR_SDK" ]; then
       echo "Cannot find $IPHONESIMULATOR_SDK"
       exit 1
      fi
      if [ ! -x "$IPHONESIMULATOR_GCC" ]; then
       echo "Cannot find $IPHONESIMULATOR_GCC"
       exit 1
      fi
      # Clean up whatever was left from our previous build
      rm -rf lib include-32 include-64
      rm -rf /tmp/curl-${CURL_VERSION}-*
      rm -rf /tmp/curl-${CURL_VERSION}-*.*-log
      build()
      {
        HOST=$1
        ARCH=$2
        GCC=$3
        SDK=$4
        MOREFLAGS=$5
       rm -rf "curl-${CURL_VERSION}"
       unzip "curl-${CURL_VERSION}.zip" -d "."
       pushd .
       cd "curl-${CURL_VERSION}"
       export IPHONEOS_DEPLOYMENT_TARGET=${MIN_VERSION}
       export CC=${GCC}
       export CFLAGS="-arch ${ARCH} -pipe -Os -gdwarf-2 -isysroot ${SDK}"
       export CPPFLAGS=${MOREFLAGS}
       export LDFLAGS="-arch ${ARCH} -isysroot ${SDK}"
       ./configure --disable-shared --enable-static --host=${HOST} --without-ssl --without-libssh2 --without-ca-bundle --without-ldap --disable-ldap --prefix="/tmp/curl-${CURL_VERSION}-${ARCH}" &> "/tmp/curl-${CURL_VERSION}-${ARCH}.log"
       make -j `sysctl -n hw.logicalcpu_max` &> "/tmp/curl-${CURL_VERSION}-${ARCH}.build-log"
       make install &> "/tmp/curl-${CURL_VERSION}-${ARCH}.install-log"
       popd
       rm -rf "curl-${CURL_VERSION}"
      }
      build "armv7-apple-darwin"  "armv7"  "${IPHONEOS_GCC}"        "${IPHONEOS_SDK}" ""
      build "armv7s-apple-darwin" "armv7s" "${IPHONEOS_GCC}"        "${IPHONEOS_SDK}" ""
      build "arm-apple-darwin"    "arm64"  "${IPHONEOS_GCC}"        "${IPHONEOS_SDK}" ""
      build "i386-apple-darwin"   "i386"   "${IPHONESIMULATOR_GCC}" "${IPHONESIMULATOR_SDK}" "-D__IPHONE_OS_VERSION_MIN_REQUIRED=${IPHONEOS_DEPLOYMENT_TARGET%%.*}0000"
      build "x86_64-apple-darwin" "x86_64" "${IPHONESIMULATOR_GCC}" "${IPHONESIMULATOR_SDK}" "-D__IPHONE_OS_VERSION_MIN_REQUIRED=${IPHONEOS_DEPLOYMENT_TARGET%%.*}0000"
      #
      mkdir -p lib include-32 include-64
      cp -r /tmp/curl-${CURL_VERSION}-i386/include/curl include-32/
      cp -r /tmp/curl-${CURL_VERSION}-x86_64/include/curl include-64/
      lipo \
      "/tmp/curl-${CURL_VERSION}-armv7/lib/libcurl.a" \
      "/tmp/curl-${CURL_VERSION}-armv7s/lib/libcurl.a" \
      "/tmp/curl-${CURL_VERSION}-arm64/lib/libcurl.a" \
      "/tmp/curl-${CURL_VERSION}-i386/lib/libcurl.a" \
      "/tmp/curl-${CURL_VERSION}-x86_64/lib/libcurl.a" \
      -create -output lib/libcurl.a
      rm -rf "/tmp/curl-${CURL_VERSION}-*"
      rm -rf "/tmp/curl-${CURL_VERSION}-*.*-log"
      

       

本文链接:https://www.it72.com/9260.htm

推荐阅读
最新回复 (0)
返回