前言
通常,需要配置host
,以及所使用的SDK
所在的目录、C
编译器路径、C++
编译器路径。
host
通常使用--host
选项进行指定。
SDK
通常使用--with-sysroot
选项或--sysroot
选项进行指定。
C
编译器可使用xcrun -f clang
取得。
C++
编译器可使用xcrun -f clang++
取得。
--prefix
选项指定构建输出目录。
--disable-shared
及--enable-static
选项指定生成静态库。
--enable-shared
及--disable-static
选项指定生成动态库。
具体选项可在各第三方库根目录下执行./configure --help
进行查看。
host
- 对于
arm64
架构,host
为aarch64-apple-darwin
- 对于
armv6
、armv7
、armv7s
架构,host
为arm-apple-darwin
- 对于
i386
架构,host
为i386-apple-darwin
- 对于
x86_64
架构,host
为x86_64-apple-darwin
SDK
- 对于
arm
架构,可使用xcrun --show-sdk-path --sdk iphoneos
取得 - 对于
i386
、x86_64
架构,可使用xcrun --show-sdk-path --sdk iphonesimulator
取得
环境变量
在编译时,也可能需要修改如下环境变量,如:
export CC="$CLANG -arch $a -isysroot $SDK"
export CXX="$CLANG_XX -arch $a -isysroot $SDK"
export CXXFLAGS="-arch $a -isysroot $SDK"
export CFLAGS="-arch $a -isysroot $SDK"
export LDFLAGS="-isysroot $SDK"
export LIBS="-L$SDK/usr/lib"
其中,
CLANG="`xcrun -f clang`"
CLANG_XX="`xcrun -f clang++`"
SDK="`xcrun --show-sdk-path --sdk iphoneXXX`"
将多个只支持单个CPU架构的库文件合并为通用库文件
lipo lib-armv7s.a lib-arm64.a -create -output lib-fat.a
lipo lib-armv7s.dylib lib-arm64.dylib -create -output lib-fat.dylib
本作品由Daniate采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。
评论已关闭