需要用到 https://github.com/leetal/ios-cmake

源码修正

修改common/almalloc.cpp ,屏蔽下面的代码

//#define ALIGNED_ALLOC_AVAILABLE (__STDC_VERSION__ >= 201112L || __cplusplus >= 201703L)
aligned_alloc 在ios13支持,早期的iOS会crash

编译

cmake 需要3.14+
每个target单独编译,用combine模式有错误。

arm64

cmake .. -DCMAKE_TOOLCHAIN_FILE=../ios.toolchain.cmake -DLIBTYPE=STATIC -DALSOFT_INSTALL=OFF -DDEPLOYMENT_TARGET=9.0 -DPLATFORM=OS64 -DCMAKE_BUILD_TYPE=Release -DALSOFT_DLOPEN=OFF
make OpenAL
make common

armv7

cmake .. -DCMAKE_TOOLCHAIN_FILE=../ios.toolchain.cmake -DLIBTYPE=STATIC -DALSOFT_INSTALL=OFF -DDEPLOYMENT_TARGET=9.0 -DARCHS=armv7 -DCMAKE_BUILD_TYPE=Release -DALSOFT_DLOPEN=OFF

x86_64

 cmake .. -DCMAKE_TOOLCHAIN_FILE=../ios.toolchain.cmake -DLIBTYPE=STATIC -DALSOFT_INSTALL=OFF -DDEPLOYMENT_TARGET=9.0 -DPLATFORM=SIMULATOR64 -DCMAKE_BUILD_TYPE=Release -DALSOFT_DLOPEN=OFF

废弃 -- i386

cmake .. -DCMAKE_TOOLCHAIN_FILE=../ios.toolchain.cmake -DLIBTYPE=STATIC -DALSOFT_INSTALL=OFF -DDEPLOYMENT_TARGET=9.0 -DPLATFORM=SIMULATOR -DCMAKE_BUILD_TYPE=Release -DALSOFT_DLOPEN=OFF

Mac x86_84

cmake .. -DLIBTYPE=STATIC -DALSOFT_INSTALL=OFF -DDEPLOYMENT_TARGET=10.11 -DCMAKE_BUILD_TYPE=Release -DALSOFT_DLOPEN=OFF -DCMAKE_OSX_ARCHITECTURES=x86_64

Mac arm64

cmake .. -DLIBTYPE=STATIC -DALSOFT_INSTALL=OFF -DDEPLOYMENT_TARGET=10.11 -DCMAKE_BUILD_TYPE=Release -DALSOFT_DLOPEN=OFF -DCMAKE_OSX_ARCHITECTURES=arm64

整合库

新建sh脚本,放到库目录下运行

#!/bin/sh
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
LIPO="xcrun -sdk iphoneos lipo"
STRIP="xcrun -sdk iphoneos strip"

$LIPO -create "$DIR"/libcommon-*.a -output "$DIR"/libcommon.a
$STRIP -S "$DIR"/libcommon.a
$LIPO -info "$DIR"/libcommon.a

$LIPO -create "$DIR"/libopenal-*.a -output "$DIR"/libopenal.a
$STRIP -S "$DIR"/libopenal.a
$LIPO -info "$DIR"/libopenal.a

标签: iOS

添加新评论