[[FrontPage]]

* boost 1.53.0 をiOS用にビルドする [#y5dfb072]

+cmakeのインストール~
iOSの開発環境にboostライブラリを追加する方法のメモです。~
以前、boost 1.49.0を入れた時はcmakeをつかいましたが、今回は、boostに付属のb2コマンドでインストールを行います。~
~
西山さんの「C++ 初心者だって Boost が iPhone で使えるんだぜ!」がとても参考になりますので、こちらも読んでください。~
http://blog.livedoor.jp/tek_nishi/archives/7603570.html

+ boostライブラリのダウンドード
-- 以下のサイトよりダウンロードできます。~
 http://www.boost.org/users/history/version_1_53_0.html
+ boostのビルド準備
-- boostライブラリを展開したディレクトリで、”bootstrap.sh"を実行する
--- "b2"コマンドがビルドされます。
-- "/usr/include/arm" にiOS SDKのARM用のライブラリヘッダをシンボリックリンクします。~
 sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/usr/include /usr/include/arm
---Xcodeのインストール場所により、/Applications/Xcode.cppが変わる事があります。古いXcodeの場合は、/Developer以下にSDKが入っています。
---"iPhoneOS6.1.sdk"の部分は、インストールされているSDKのバージョンに合わせてください。
+ ビルド開始
-- 以下のシェルスクリプトで実行します

 #!/bin/bash
 export SDK_NAME=iPhoneOS6.1.sdk
 export SDK_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Dev  eloper/SDKs/$SDK_NAME 
 export B2_FLAGS='architecture=arm target-os=iphone link=static threading=multi  define=_LITTLE_ENDIAN'
 export B2_CFLAGS='-fvisibility=default -miphoneos-version-min=5.0'
 #
 # build boost
 #
 rm -rf stage/lib
 ./b2 toolset=clang cflags="-arch armv7 $B2_CFLAGS" $B2_FLAGS include=$SDK_PATH/usr/include/
 mv stage/lib stage/lib_armv7
 ./b2 toolset=clang cflags="-arch armv7 $B2_CFLAGS" $B2_FLAGS include=$SDK_PATH/usr/include/ --clean
 ./b2 toolset=clang cflags="-arch armv7s $B2_CFLAGS" $B2_FLAGS include=$SDK_PATH/usr/include/
 mv stage/lib stage/lib_armv7s
 ./b2 toolset=clang cflags="-arch armv7s $B2_CFLAGS" $B2_FLAGS include=$SDK_PATH/usr/include/ --clean
 ./b2 toolset=clang cflags="-arch i386 $B2_CFLAGS" $B2_FLAGS  include=$SDK_PATH/usr/include/
 mv stage/lib stage/lib_i386
 #
 # marge librarys
 #
 mkdir stage/lib
 for name in $(ls stage/lib_armv7); do
 lipo -create stage/lib_armv7/$name stage/lib_armv7s/$name stage/lib_i386/$name -output   stage/lib/$name
 done

* boost 1.49.0 をiOS用にビルドする [#j31342db]

Matt.Galloway さんのブログより拝借
http://iphone.galloway.me.uk/2010/09/compiling-boost-1-44-for-iphone/

 # <grab source from boost.org>
 # download boost_1_49_0.tar.gz and extract any directory
 cd boost_1_49_0
 ./bootstrap.sh
  
 # Set this to whatever you want to build against
 SDK_VERSION="4.2"
  
 # Install for device:
 ./bjam --prefix=${HOME}/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDK_VERSION}.sdk/usr toolset=darwin architecture=arm target-os=iphone macosx-version=iphone-${SDK_VERSION} define=_LITTLE_ENDIAN link=static install
  
 # Install for simulator
 ./bjam --prefix=${HOME}/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${SDK_VERSION}.sdk/usr toolset=darwin architecture=x86 target-os=iphone macosx-version=iphonesim-${SDK_VERSION} link=static install

1.49.0では、SDK4.2までのサポートのようで、5.1にしたらエラーになった。

** そのうちrypplでサポートされるかも。 [#u7535aac]

* cmakeのインストール (1.41.0限定) [#bc4a5ebb]
http://www.cmake.org/cmake/resources/software.html
+boost.orgよりCMake対応のソースをSVNのリポジトリからチェックアウトする
 $ mkdir ~/boost
+boost.orgよりCMake対応のソースをSVNのリポジトリから/usr/local/srcにチェックアウトする
 $ cd /usr/local/src
 $ mkdir boost
 $ svn co http://svn.boost.org/svn/boost/branches/CMake/release
 $ mv release boost.cmake
 $ mv release boost-1.41.0-cmake
+Xcode 用のプロジェクトファイルを生成するために、以下のコマンドを順番に実行する。
 $ cd boost.cmake
 $ cd boost-1.41.0-cmake
 $ cmake -GXcode .
 $ cmake -DCMAKE_IS_EXPERIMENTAL=YES_I_KNOW .
+Xcodeから Boost.xcodeprojを開く
 $ open Boost.xcodeproj
+ビルド設定をする~
「プロジェクト」→「プロジェクト設定を編集」でウインドウが開く~
「一般」タグ内の「すべての構成のベースSDK」を「iPhone デバイス x.x」に設定する~
「一般」タグ内の「すべての構成のベースSDK」を「iOS x.x」に設定する~
+使用したいスタティックライブラリをビルドする~
メインウインドウの左上のボタンで「アクティブSDK」「アクティブな構成」を適当に設定~
メインウインドウの左のペインの「ターゲット」リストから、ビルドしたいライブラリを見つけてビルドする。~
スタティックライブラリのターゲット名は必ず「libboost_???.a」になっています。~
sharedライブラリはビルドエラーになる。"*.static"のプロジェクトのみビルド可能~ 
Debugビルドの場合、lib/Debug/libboost_XXXX-mt.aが生成される。~

** boostのスタティックライブラリのリンク時の問題 [#a52ac2ad]

***xxx has different visiblity (default) in ... という warning が大量に出る [#bcb63e2a]

+ boostのプロジェクトをXcodeで開く
+ ターゲットにある各モジュールのスタティックライブラリをダブルクリックしてプロジェクトの設定画面を出す
+ 下の方にある"OTHER_CPLUSPLUSFLAGS"に"-fvisibility=hidden"を追加する。

*** Deviceでビルドしたときにスタティックライブラリがリンクエラーになる場合 [#nede11fa]

http://blog.slidetorock.com/linking-a-static-library-with-xcode-322-and-s

***デバイスに転送したPNGファイルが読めない [#m66de64e]
http://akisute.com/2009/10/iphonepnglibpng.html


トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS