ios版boost庫編譯

2021-07-25 17:01:55 字數 4200 閱讀 4122

#!/bin/bash

# 請自行修改路徑,cd到boost解壓後的目錄下

dir=`dirname $0`

cd "$dir/../../public_libs/boost_1_56_0"

# 如果庫檔案已存在,直接退出

if [ -e ./stage/lib/libboost_date_time.a ]; then

echo "libraries exist. no need to build."

exit 0

fi: $

: $: $

: $echo "iphone_sdkversion: $iphone_sdkversion"

echo "xcode_root: $xcode_root"

echo "compiler: $compiler"

echo "bootstrap"

# 此指令碼如果是被xcode呼叫的話,會因為xcode export的某些變數導致失敗,所以加了env -i。直接在命令列執行此指令碼可以把env -i 去掉

env -i bash ./bootstrap.sh

echo "write project-config.jam"

# 預設生存的project-config.jam是編譯mac版的,這裡直接調換掉

rm project-config.jam

cat >> project-config.jam <$xcode_root/platforms/iphoneos.platform/developer

: arm iphone

;using darwin : $~iphonesim

: $xcode_root/toolchains/xcodedefault.xctoolchain/usr/bin/$compiler -arch i386 -arch x86_64 $extra_cppflags

: $xcode_root/platforms/iphonesimulator.platform/developer

: ia64 iphone

;eof

# 上面的**裡,兩個using darwin分別是編譯真機版和模擬器版的設定。每多一種cpu架構就要再加乙個-arch ***。

echo "build boost iphone dev"

./bjam -j16 --with-iostreams --with-regex --with-timer --with-exception --with-chrono --with-serialization --with-signals --with-date_time --with-filesystem --with-system --with-thread --build-dir=iphone-build --stagedir=iphone-build/stage toolset=darwin architecture=arm target-os=iphone macosx-version=iphone-$ define=_little_endian link=static stage

echo "build boost iphone sim"

./bjam -j16 --with-iostreams --with-regex --with-timer --with-exception --with-chrono --with-serialization --with-signals --with-date_time --with-filesystem --with-system --with-thread --build-dir=iphonesim-build --stagedir=iphonesim-build/stage --toolset=darwin-$~iphonesim architecture=ia64 target-os=iphone macosx-version=iphonesim-$ link=static stage cxxflags=-miphoneos-version-min=7.0

echo "lipo"

# 把各架構下的庫檔案合一,以便在xcode裡可以少設定些搜尋路徑。做得更徹底些是各個分庫合成乙個大庫。不過除非是把靜態庫加入到**倉庫,否則是浪費時間了。要合成的大庫話請參考原文。

mkdir -p stage/lib

lipo -create iphone-build/stage/lib/libboost_iostreams.a iphonesim-build/stage/lib/libboost_iostreams.a -output stage/lib/libboost_iostreams.a

lipo -create iphone-build/stage/lib/libboost_regex.a iphonesim-build/stage/lib/libboost_regex.a -output stage/lib/libboost_regex.a

lipo -create iphone-build/stage/lib/libboost_timer.a iphonesim-build/stage/lib/libboost_timer.a -output stage/lib/libboost_timer.a

lipo -create iphone-build/stage/lib/libboost_exception.a iphonesim-build/stage/lib/libboost_exception.a -output stage/lib/libboost_exception.a

lipo -create iphone-build/stage/lib/libboost_chrono.a iphonesim-build/stage/lib/libboost_chrono.a -output stage/lib/libboost_chrono.a

lipo -create iphone-build/stage/lib/libboost_serialization.a iphonesim-build/stage/lib/libboost_serialization.a -output stage/lib/libboost_serialization.a

lipo -create iphone-build/stage/lib/libboost_signals.a iphonesim-build/stage/lib/libboost_signals.a -output stage/lib/libboost_signals.a

lipo -create iphone-build/stage/lib/libboost_atomic.a iphonesim-build/stage/lib/libboost_atomic.a -output stage/lib/libboost_atomic.a

lipo -create iphone-build/stage/lib/libboost_wserialization.a iphonesim-build/stage/lib/libboost_wserialization.a -output stage/lib/libboost_wserialization.a

lipo -create iphone-build/stage/lib/libboost_date_time.a iphonesim-build/stage/lib/libboost_date_time.a -output stage/lib/libboost_date_time.a

lipo -create iphone-build/stage/lib/libboost_filesystem.a iphonesim-build/stage/lib/libboost_filesystem.a -output stage/lib/libboost_filesystem.a

lipo -create iphone-build/stage/lib/libboost_system.a iphonesim-build/stage/lib/libboost_system.a -output stage/lib/libboost_system.a

lipo -create iphone-build/stage/lib/libboost_thread.a iphonesim-build/stage/lib/libboost_thread.a -output stage/lib/libboost_thread.a

# 庫檔案最終放在./stage/lib/下

echo "completed successfully"

另外 extra_cppflags

那邊原本加入了 -dboost_ac_use_pthreads -dboost_sp_use_pthreads

兩個巨集,應該去掉

boost庫交叉編譯

1.環境 linux系統 ubuntu 14.04 編譯工具 arm fsl linux gnueabi gcc 3.編譯 1 解壓,cd 到目錄 show libraries可檢視所有庫,如下 使用 without libraries 逗號隔開去掉不想編譯的庫,prefix 指定編譯後的安裝路徑 ...

交叉編譯boost庫

1.確保arm編譯成功安裝,並配置好環境變數。2.解壓boost壓縮包 3.進入目錄執行.bootstrap.sh,此時形成bjam檔案和project config.jam using gcc arm linux gnueabihf gcc 注意是雙冒號 5.執行.bjam stage,ok大功告...

boost 編譯 thread asio 等庫

2.將bjam.exe放在c boost 1 46 1目錄下 3.編譯thread庫 bjam.exe stage with thread toolset msvc runtime link static 編譯asio庫 bjam.exe stage with system toolset msvc...