首页 > 代码库 > iOS 通用交叉编译脚本
iOS 通用交叉编译脚本
唔. 一般在pc上我们都是
./configure
make
make install
一套打完收工..但是ios上怎么破.?
-0- 主要是一些环境需要手动配置...
这里写了一些比较常见的环境.
把这玩意放到configure同路径下. 执行这脚本就OK了.
测试bson和lame库都OK
#!/bin/bash BUILD_I386_IOS_SIM=1 BUILD_ARMV7_IPHONE=1 BUILD_ARMV7S_IPHONE=1 BUILD_TARGET=lame IOS_MIN_SDK=6.1 ( PWD=`pwd` PREFIX=${PWD}/${BUILD_TARGET} rm -rf ${PREFIX}/platform mkdir -p ${PREFIX}/platform EXTRA_MAKE_FLAGS="-j4" XCODEDIR=`xcode-select --print-path` IOS_SDK=$(xcodebuild -showsdks | grep iphoneos | sort | head -n 1 | awk '{print $NF}') SIM_SDK=$(xcodebuild -showsdks | grep iphonesimulator | sort | head -n 1 | awk '{print $NF}') IPHONEOS_PLATFORM=${XCODEDIR}/Platforms/iPhoneOS.platform IPHONEOS_SYSROOT=${IPHONEOS_PLATFORM}/Developer/SDKs/${IOS_SDK}.sdk IPHONESIMULATOR_PLATFORM=${XCODEDIR}/Platforms/iPhoneSimulator.platform IPHONESIMULATOR_SYSROOT=${IPHONESIMULATOR_PLATFORM}/Developer/SDKs/${SIM_SDK}.sdk CC=clang CFLAGS="-DNDEBUG -g -O0 -pipe -fPIC -fcxx-exceptions" CXX=clang CXXFLAGS="${CFLAGS} -std=c++11 -stdlib=libc++" LDFLAGS="-stdlib=libc++" LIBS="-lc++ -lc++abi" if [ $BUILD_ARMV7_IPHONE -eq 1 ] then echo "##################" echo " armv7 for iPhone" echo "##################" ( cd ${PWD} make ${EXTRA_MAKE_FLAGS} distclean ./configure --build=x86_64-apple-darwin13.0.0 --host=armv7-apple-darwin13.0.0 --enable-static --disable-shared --prefix=${PREFIX} "CC=${CC}" "CFLAGS=${CFLAGS} -miphoneos-version-min=${IOS_MIN_SDK} -arch armv7 -isysroot ${IPHONEOS_SYSROOT}" "CXX=${CXX}" "CXXFLAGS=${CXXFLAGS} -arch armv7 -isysroot ${IPHONEOS_SYSROOT}" LDFLAGS="-arch armv7 -miphoneos-version-min=${IOS_MIN_SDK} ${LDFLAGS}" "LIBS=${LIBS}" make ${EXTRA_MAKE_FLAGS} make ${EXTRA_MAKE_FLAGS} install cd ${PREFIX}/platform rm -rf armv7 mkdir armv7 cp ${PREFIX}/lib/*.a ${PREFIX}/platform/armv7 ) ARMV7_IPHONE_OUTPUT=`find ${PREFIX}/platform/armv7/*.a` else ARMV7_IPHONE_OUTPUT= fi if [ $BUILD_ARMV7S_IPHONE -eq 1 ] then echo "###################" echo " armv7s for iPhone" echo "###################" ( cd ${PWD} make ${EXTRA_MAKE_FLAGS} distclean ./configure --build=x86_64-apple-darwin13.0.0 --host=armv7s-apple-darwin13.0.0 --enable-static --disable-shared --prefix=${PREFIX} "CC=${CC}" "CFLAGS=${CFLAGS} -miphoneos-version-min=${IOS_MIN_SDK} -arch armv7s -isysroot ${IPHONEOS_SYSROOT}" "CXX=${CXX}" "CXXFLAGS=${CXXFLAGS} -arch armv7s -isysroot ${IPHONEOS_SYSROOT}" LDFLAGS="-arch armv7s -miphoneos-version-min=${IOS_MIN_SDK} ${LDFLAGS}" "LIBS=${LIBS}" make ${EXTRA_MAKE_FLAGS} make ${EXTRA_MAKE_FLAGS} install cd ${PREFIX}/platform rm -rf armv7s mkdir armv7s cp ${PREFIX}/lib/*.a ${PREFIX}/platform/armv7s ) ARMV7S_IPHONE_OUTPUT=`find ${PREFIX}/platform/armv7s/*.a` else ARMV7S_IPHONE_OUTPUT= fi if [ $BUILD_I386_IOS_SIM -eq 1 ] then echo "###########################" echo " i386 for iPhone Simulator" echo "###########################" ( cd ${PWD} make ${EXTRA_MAKE_FLAGS} distclean ./configure --build=x86_64-apple-darwin13.0.0 --host=i386-apple-darwin13.0.0 --enable-static --disable-shared --prefix=${PREFIX} "CC=${CC}" "CFLAGS=${CFLAGS} -miphoneos-version-min=${IOS_MIN_SDK} -arch i386 -isysroot ${IPHONESIMULATOR_SYSROOT}" "CXX=${CXX}" "CXXFLAGS=${CXXFLAGS} -arch i386 -isysroot ${IPHONESIMULATOR_SYSROOT}" LDFLAGS="-arch i386 -miphoneos-version-min=${IOS_MIN_SDK} ${LDFLAGS}" "LIBS=${LIBS}" make ${EXTRA_MAKE_FLAGS} make ${EXTRA_MAKE_FLAGS} install cd ${PREFIX}/platform rm -rf sim mkdir sim cp ${PREFIX}/lib/*.a ${PREFIX}/platform/sim ) IOS_SIM_OUTPUT=`find ${PREFIX}/platform/sim/*.a` else IOS_SIM_OUTPUT= fi echo "############################" echo " Create Mixd Libraries" echo "############################" ( cd ${PREFIX}/platform rm -rf mixd mkdir -p mixd lipo ${IOS_SIM_OUTPUT} ${ARMV7_IPHONE_OUTPUT} ${ARMV7S_IPHONE_OUTPUT} -create -output ${PREFIX}/platform/mixd/lib${BUILD_TARGET}.a ) ) 2>&1 #) >build.log 2>&1 echo "done"
iOS 通用交叉编译脚本
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。