这个脚本更智能化一点,不需要配置xcode相关的路径(其实是根据系统安装的xcode自动搜索到相关的路径),下面2个脚本,一个编译ssh的,另外一个是curl的。修正 了curl下载路径不正确的问题。
不知道是不是系统问题,换了几个编译的方法都是提示
ios-build-libssl.sh
ios-build-libcurl.sh
最后还有一个简单的说明 使用终端操作: ################################################################################## 切换到当前目录 输入命令./ios-build-libcurl.sh 回车 就可以全自动下载、编译curl+ssl
---------------------------------------------------------------------------------- 如果使用终端下载太慢,可以从官网下载对应的版本如下放置: dir/ios-build-libcurl.sh dir/ios-build-libssl.sh dir/Readme.txt dir/Curl/curl-7.40.0.tar.gz dir/OpenSSL/openssl-1.0.1k.tar.gz
$cd dir $./ios-build-libcurl.sh 回车即可
Curl 下载地址:http://curl.haxx.se/download/ OpenSSL 下载地址:https://www.openssl.org/source/ ----------------------------------------------------------------------------------
默认使用openssl-1.0.1k版本 默认使用curl-7.40.0版本
生成ARCHS="i386 x86_64 armv7 armv7s arm64" 5个平台的.a库供iOS开发使用 (使用xcode6.1 SDK8.1测试使用正常)
----------------------------------------------------------------------------------
寒岩整理制作 mail:939767926@qq.com date:2014-01-2 11:51:00 ################################################################################## 文件列表: ################################################################################## Readme.txt ios-build-libcurl.sh ios-build-openSSL.sh ################################################################################## 环境说明: ################################################################################## 默认使用4.0更改默认Xcode 例如sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer ################################################################################## 生成文件说明: ################################################################################## ./OpenSSL/bin 分别保存不同平台的生成文件 ./OpenSSL/inclde 保存需用到的.h文件 ./OpenSSL/lib 保存跨平台的公用.a ./OpenSSL/src 源码解压位置 ./OpenSSL/openssl-1.0.1k.tar.gz 下载包
----------------------------------------------------------------------------------
./Curl/bin 分别保存不同平台的生成文件 ./Curl/inclde 保存需用到的.h文件 ./Curl/lib 保存跨平台的公用.a ./Curl/src 源码解压位置 ./Curl/Curl-7.40.0.tar.gz 下载包
----------------------------------------------------------------------------------
查看./Curl/bin/${target}-${arch}.sdk/build-curl-${Version}.log文件获知libcurl.a库的配置信息 ################################################################################## 项目开发使用文件: ################################################################################## ./OpenSSL/inclde/openssl/* ./OpenSSL/lib/* ./Curl/inclde/curl/* ./Curl/lib/* ##################################################################################
不知道是不是系统问题,换了几个编译的方法都是提示
url.c:55:2: error: "We can't compile without socket() support!"
好是雷人,有空换个系统看下。这个socket居然不能编译通过……
执行ios-build.libcurl.sh即可,因为它包含了...ssh.shios-build-libssl.sh
#!/bin/sh # Automatic build script for libssl and libcrypto # for iPhoneOS and iPhoneSimulator # # Created by Felix Schulze on 16.12.10. # Copyright 2010 Felix Schulze. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ########################################################################### # Change values here # # VERSION="1.0.1k" # SDKVERSION=`xcrun -sdk iphoneos --show-sdk-version` # # # ########################################################################### # # # Don't change anything under this line! # # # ########################################################################### CURRENTPATH=`pwd` ARCHS="i386 x86_64 armv7 armv7s arm64" DEVELOPER=`xcode-select -print-path` #检测XCode环境 if [ ! -d "$DEVELOPER" ]; then echo "xcode path is not set correctly $DEVELOPER does not exist (most likely because of xcode > 4.3)" echo "run" echo "sudo xcode-select -switch" echo "for default installation:" echo "sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer" exit 1 fi case $DEVELOPER in *\ * ) echo "Your Xcode path contains whitespaces, which is not supported." exit 1 ;; esac case $CURRENTPATH in *\ * ) echo "Your path contains whitespaces, which is not supported by 'make install'." exit 1 ;; esac mkdir -p "OpenSSL" cd "OpenSSL" CURRENTPATH=`pwd` #检测.tar.gz包是否存在 set -e if [ ! -e openssl-${VERSION}.tar.gz ]; then echo "Downloading openssl-${VERSION}.tar.gz" curl -O https://www.openssl.org/source/openssl-${VERSION}.tar.gz else echo "Using openssl-${VERSION}.tar.gz" fi mkdir -p "${CURRENTPATH}/src" mkdir -p "${CURRENTPATH}/bin" mkdir -p "${CURRENTPATH}/lib" tar zxf openssl-${VERSION}.tar.gz -C "${CURRENTPATH}/src" cd "${CURRENTPATH}/src/openssl-${VERSION}" for ARCH in ${ARCHS} do if [[ "${ARCH}" == "i386" || "${ARCH}" == "x86_64" ]]; then PLATFORM="iPhoneSimulator" else sed -ie "s!static volatile sig_atomic_t intr_signal;!static volatile intr_signal;!" "crypto/ui/ui_openssl.c" PLATFORM="iPhoneOS" fi export CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer" export CROSS_SDK="${PLATFORM}${SDKVERSION}.sdk" export BUILD_TOOLS="${DEVELOPER}" echo "Building openssl-${VERSION} for ${PLATFORM} ${SDKVERSION} ${ARCH}" echo "Please stand by..." export CC="${BUILD_TOOLS}/usr/bin/gcc -arch ${ARCH}" mkdir -p "${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" LOG="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/build-openssl-${VERSION}.log" set +e if [[ "$VERSION" =~ 1.0.0. ]]; then ./Configure BSD-generic32 --openssldir="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" > "${LOG}" 2>&1 elif [ "${ARCH}" == "x86_64" ]; then ./Configure darwin64-x86_64-cc --openssldir="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" > "${LOG}" 2>&1 else ./Configure iphoneos-cross --openssldir="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" > "${LOG}" 2>&1 fi if [ $? != 0 ]; then echo "Problem while configure - Please check ${LOG}" exit 1 fi # add -isysroot to CC= sed -ie "s!^CFLAG=!CFLAG=-isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK} -miphoneos-version-min=7.0 !" "Makefile" if [ "$1" == "verbose" ]; then make else make >> "${LOG}" 2>&1 fi if [ $? != 0 ]; then echo "Problem while make - Please check ${LOG}" exit 1 fi set -e make install >> "${LOG}" 2>&1 make clean >> "${LOG}" 2>&1 done echo "Build library..." lipo -create ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-i386.sdk/lib/libssl.a ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-x86_64.sdk/lib/libssl.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7.sdk/lib/libssl.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7s.sdk/lib/libssl.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-arm64.sdk/lib/libssl.a -output ${CURRENTPATH}/lib/libssl.a lipo -create ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-i386.sdk/lib/libcrypto.a ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-x86_64.sdk/lib/libcrypto.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7.sdk/lib/libcrypto.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7s.sdk/lib/libcrypto.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-arm64.sdk/lib/libcrypto.a -output ${CURRENTPATH}/lib/libcrypto.a mkdir -p ${CURRENTPATH}/include cp -R ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-i386.sdk/include/openssl ${CURRENTPATH}/include/ echo "Building done." echo "Cleaning up..." rm -rf ${CURRENTPATH}/src/openssl-${VERSION} echo "Done."
ios-build-libcurl.sh
#!/bin/sh # Automatic build script for libcurl # for iPhoneOS and iPhoneSimulator # # Created by Rockee on 2012-7-26. # Copyright 2012 Rockee. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ########################################################################### # Change values here # # # VERSION="7.48.0" # SDKVERSION=`xcrun -sdk iphoneos --show-sdk-version` # DEVELOPER=`xcode-select -print-path` # ARCHS="i386 x86_64 armv7 armv7s arm64" # # # ########################################################################### # # # Don't change anything under this line! # # # ########################################################################### xcodebuild -version #developer root path xcode-select -print-path #developer sdk version xcrun -sdk iphoneos --show-sdk-version xcrun -sdk iphonesimulator --show-sdk-version #developer sdk path xcrun -sdk iphoneos --show-sdk-path xcrun -sdk iphonesimulator --show-sdk-path #developer cmd path xcrun --sdk iphoneos --find clang xcrun --sdk iphoneos --find clang++ ########################################################################### # # # # # Build oppenSSL # # # echo "##################################################################" # echo "########################## Build openSSL #########################" # ./ios-build-libssl.sh # echo "########################## Build openSSL End!#####################" # echo "##################################################################" # # # # # ########################################################################### echo "##################################################################" echo "########################## Build libcurl #########################" CURRENTPATH=$(pwd) #获取当前目录绝对路径 echo "--OK!------ 当前目录:${CURRENTPATH}" SSLPATH="${CURRENTPATH}/OpenSSL" echo "--OK!------ 第三方库:${SSLPATH}" mkdir -p "Curl" cd "Curl" CURRENTPATH=$(pwd) #获取当前目录绝对路径 echo "--OK!------ 当前目录:${CURRENTPATH}" #判断是否安装Xcode.app if [ ! \( -d "$DEVELOPER" \) ] ; then echo "--ERR:------ 编译工具:The iPhone SDK could not be found.Folder: \"$DEVELOPER\" does not exist." exit 1 else echo "--OK!------ 编译工具:The iPhone SDK be found!!" fi set -e #判断当前目录下是否有curl-VERSION.tar.gz压缩包 if [ ! -e curl-${VERSION}.tar.gz ] ; then echo "--OK!------ 下载文件:curl-${VERSION}.tar.gz" curl -O https://curl.haxx.se/download/curl-${VERSION}.tar.gz else echo "--OK!------ 使用文件:curl-${VERSION}.tar.gz" fi mkdir -p "${CURRENTPATH}/src" mkdir -p "${CURRENTPATH}/bin" mkdir -p "${CURRENTPATH}/lib" echo "--OK!------ 创建目录:${CURRENTPATH}/src" echo "--OK!------ 创建目录:${CURRENTPATH}/bin" echo "--OK!------ 创建目录:${CURRENTPATH}/lib" tar zxf curl-${VERSION}.tar.gz -C "${CURRENTPATH}/src" #将压缩包解压缩到src下 echo "--OK!------ 解压文件:curl-${VERSION}.tar.gz到${CURRENTPATH}/src" cd "${CURRENTPATH}/src/curl-${VERSION}" #进入到curl文件夹下 echo "--OK!------ 进入目录:${CURRENTPATH}/src/curl-${VERSION}" #获取当前目录绝对路径 BUILDPATH=$(pwd) echo "--OK!------ 当前目录:${BUILDPATH}" for ARCH in ${ARCHS} do echo "##################BUILDIT(${ARCH} , ${ARCH})##################" export IPHONEOS_DEPLOYMENT_TARGET="7.0" export CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer" export CROSS_SDK="${PLATFORM}${SDKVERSION}.sdk" export BUILD_TOOLS="${DEVELOPER}" if [[ "${ARCH}" == "i386" || "${ARCH}" == "x86_64" ]]; then echo "##################BUILDIT(${ARCH} , ${ARCH})##################" PLATFORM="iPhoneSimulator" SDKTYPE="iphonesimulator" export CC=$(xcrun --sdk $SDKTYPE --find clang) export CXX=$(xcrun --sdk $SDKTYPE --find clang++) export CFLAGS="-arch ${ARCH} -pipe -Os -gdwarf-2 -isysroot $(xcrun --sdk $SDKTYPE --show-sdk-path) -mios-simulator-version-min=$IPHONEOS_DEPLOYMENT_TARGET" export LDFLAGS="-L${SSLPATH}/bin/${platform}${SDK}-${target}.sdk/lib" export PKG_CONFIG_PATH="${SSLPATH}/bin/${platform}${SDK}-${target}.sdk/lib/pkgconfig" mkdir -p "${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" LOG="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/build-curl-${VERSION}.log" ./configure --disable-shared --enable-static --host="${ARCH}-apple-darwin" --with-ssl=$SSLPATH --prefix="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/" > "${LOG}" 2>&1 else PLATFORM="iPhoneOS" SDKTYPE="iphoneos" export CC=$(xcrun --sdk $SDKTYPE --find clang) export CXX=$(xcrun --sdk $SDKTYPE --find clang++) export CFLAGS="-arch ${ARCH} -pipe -Os -gdwarf-2 -isysroot $(xcrun --sdk $SDKTYPE --show-sdk-path) -miphoneos-version-min=$IPHONEOS_DEPLOYMENT_TARGET" export LDFLAGS="-L${SSLPATH}/bin/${platform}${SDK}-${target}.sdk/lib" export PKG_CONFIG_PATH="${SSLPATH}/bin/${platform}${SDK}-${target}.sdk/lib/pkgconfig" mkdir -p "${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" LOG="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/build-curl-${VERSION}.log" if [[ "${ARCH}" = "arm64" ]]; then ./configure --disable-shared --enable-static --enable-threaded-resolver --host="aarch64-apple-darwin" --with-ssl=$SSLPATH --prefix="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/" > "${LOG}" 2>&1 else ./configure --disable-shared --enable-static --enable-threaded-resolver --host="${ARCH}-apple-darwin" --with-ssl=$SSLPATH --prefix="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/" > "${LOG}" 2>&1 fi fi make #make -j `sysctl -n hw.logicalcpu_max` cp lib/.libs/libcurl.a ../../bin/libcurl-${ARCH}.a make clean echo "--OK!------ Install bin/libcurl-${ARCH}.a OK!" echo "################BUILDIT(${target} , ${platform}) End!################" echo "#####################################################################" done echo "--OK!------ ############################################################" echo "--OK!------ Build library..." #归档公用库 #lipo -create ${CURRENTPATH}/bin/libcurl.armv7.a ${CURRENTPATH}/bin/libcurl.i386.a -output ${CURRENTPATH}/lib/libcurl.a LIBCURL_SRC="" for ARCH in ${ARCHS} do if [[ "${ARCH}" == "i386" || "${ARCH}" == "x86_64" ]]; then LIBCURL_SRC="${LIBCURL_SRC}${CURRENTPATH}/bin/libcurl-${ARCH}.a " else LIBCURL_SRC="${LIBCURL_SRC}${CURRENTPATH}/bin/libcurl-${ARCH}.a " fi done lipo -create ${LIBCURL_SRC} -output ${CURRENTPATH}/lib/libcurl.a mkdir -p ${CURRENTPATH}/include cp -R ${BUILDPATH}/include ${CURRENTPATH}/ echo "--OK!------ Building done." echo "--OK!------ Cleaning up..." rm -rf ${CURRENTPATH}/src/curl-${VERSION} echo "--OK!------ Done." echo "--OK!------ ############################################################"
最后还有一个简单的说明 使用终端操作: ################################################################################## 切换到当前目录 输入命令./ios-build-libcurl.sh 回车 就可以全自动下载、编译curl+ssl
---------------------------------------------------------------------------------- 如果使用终端下载太慢,可以从官网下载对应的版本如下放置: dir/ios-build-libcurl.sh dir/ios-build-libssl.sh dir/Readme.txt dir/Curl/curl-7.40.0.tar.gz dir/OpenSSL/openssl-1.0.1k.tar.gz
$cd dir $./ios-build-libcurl.sh 回车即可
Curl 下载地址:http://curl.haxx.se/download/ OpenSSL 下载地址:https://www.openssl.org/source/ ----------------------------------------------------------------------------------
默认使用openssl-1.0.1k版本 默认使用curl-7.40.0版本
生成ARCHS="i386 x86_64 armv7 armv7s arm64" 5个平台的.a库供iOS开发使用 (使用xcode6.1 SDK8.1测试使用正常)
----------------------------------------------------------------------------------
寒岩整理制作 mail:939767926@qq.com date:2014-01-2 11:51:00 ################################################################################## 文件列表: ################################################################################## Readme.txt ios-build-libcurl.sh ios-build-openSSL.sh ################################################################################## 环境说明: ################################################################################## 默认使用4.0
----------------------------------------------------------------------------------
./Curl/bin 分别保存不同平台的生成文件 ./Curl/inclde 保存需用到的.h文件 ./Curl/lib 保存跨平台的公用.a ./Curl/src 源码解压位置 ./Curl/Curl-7.40.0.tar.gz 下载包
----------------------------------------------------------------------------------
查看./Curl/bin/${target}-${arch}.sdk/build-curl-${Version}.log文件获知libcurl.a库的配置信息 ################################################################################## 项目开发使用文件: ################################################################################## ./OpenSSL/inclde/openssl/* ./OpenSSL/lib/* ./Curl/inclde/curl/* ./Curl/lib/* ##################################################################################
收藏的用户(0) X
正在加载信息~
推荐阅读
最新回复 (0)
站点信息
- 文章2300
- 用户1336
- 访客10863260
每日一句
True success inspires others to act.
真正的成功是激励他人行动。
真正的成功是激励他人行动。
新会员