下载并解压源码,下载路径(来自https://www.boost.org/users/download/),现在以1.77为例:https://boostorg.jfrog.io/artifactory/main/release/1.77.0/source/boost_1_77_0.tar.bz2
2,运行bootstrap.sh解压进入booost库目录,命令行运行:
./bootstrap.sh
假如你只想编译某个库:
./bootstrap.sh --with-libraries=context3,修改project-config.jam,在末尾增加一下内容:
# IOS ARM64 using clang : iphoneos : xcrun clang -arch arm64 -stdlib=libc++ -std=c++11 -miphoneos-version-min=12.0 -fvisibility-inlines-hidden -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk ; # IOS x86_64 using clang : iphonesimulator : xcrun clang -arch x86_64 -stdlib=libc++ -std=c++11 -miphoneos-version-min=12.0 -fvisibility-inlines-hidden -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk ;4,编译处理单个库,把各个架构合并。例如libboost_context.a
lib=libboost_context.a dir='stage/lib' # Build arm64 ./b2 -a -j4 toolset=clang-iphoneos binary-format=mach-o abi=aapcs link=static stage mv $dir/$lib $dir/arm64_$lib # Build x86_64 ./b2 -a -j4 toolset=clang-iphonesimulator binary-format=mach-o abi=sysv link=static stage mv $dir/$lib $dir/x86_64_$lib # Make fat lipo -create $dir/arm64_$lib $dir/x86_64_$lib -output $dir/$lib5,编译多个库,把各个架构合并
dir='stage/lib'
# Build arm64
./b2 -a -j4 toolset=clang-iphoneos binary-format=mach-o abi=aapcs link=static stage
mkdir $dir/arm64
mv $dir/ $dir/arm64
# Build x86_64
./b2 -a -j4 toolset=clang-iphonesimulator binary-format=mach-o abi=sysv link=static stage
mkdir $dir/x86_64
mv $dir/ $dir/x86_64
# Make fat
for i in `find $dir/arm64 -name "*.a" -exec basename {} ;`
do
echo $i
lipo -create $dir/arm64/$i $dir/x86_64/$i -output stage/lib/$i
done
6,测试#includeusing namespace boost; //名字空间 #include using namespace std; int main() { //mt19937 马特赛特旋转演算法,适用于很多场景 mt19937 mt(time(0)); cout << "随机数范围" << mt.min() << "~" << mt.max() << endl; }



