UPDATE: For the latest boost and iOS 6, clone this repo instead, it should “just work”: https://gitorious.org/~galbraithjoseph/boostoniphone/galbraithjosephs-boostoniphone Thanks Galbraith!
First of all, Apple haven’t updated the path given by xcode-select since 4.3. xcode-select -print-path will output “/Developer”. To update it for Xcode 4.3’s new pathing, simply run:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
I have cloned the git repository of the excellent boost iOS framework script found here: http://goodliffe.blogspot.co.uk/2010/09/building-boost-framework-for-ios-iphone.html
You can download all the necessary files from here, which most importantly contains the updated shell script:
https://gitorious.org/~danielsefton/boostoniphone/danielseftons-boostoniphone
(You will find an xcode directory in there: I haven’t touched this and it probably won’t work – but this method is easier, trust me).
We’ll need to sacrifice some automation for now. I have commented out functionality for automatically unpacking the tar.bz file. Once you have cloned the repo, follow these steps:
1) Unpack boost_1_49_0.tar.bz2
2) Apply the “xcode_43.diff” patch from here: https://svn.boost.org/trac/boost/ticket/6686 – Note: This is a temporary fix until boost officially supports Xcode 4.3. This may be an unnecessary step in the near future. When it is, it will be safe to re-enable auto unpacking by uncommenting “rm -rf $BOOST_SRC” in “cleanEverythingReadyToStart()” and “unpackBoost” after “Execution starts here”.
3) Run:
bash boost.sh
4) Wait and enjoy!
5) Note: If for any reason you wish to run the script again, because the script will not clean the boost build folder due to the patch we applied, you will get duplication errors in tools/build/v2/user-config.jam. Simply open it up and remove any code under “Python configuration”. Then you can happily re-run the script.
A final thanks to the following link for helping me update the script:
http://stackoverflow.com/questions/9100723/using-boostfilesysystem-path-from-framework-on-ios
Thank you so much! Works 🙂
I’ve done all the steps but I got “cc command not found” error in boostrap.log.
Any suggestion ?
It turns out I just need to install command line tools from Xcode Preferences. After that the framework is build just fine.
Hi, thank you for the script, however I do seem to have a problem compiling. It ends with the message “Aborted: Lipo thread failed”, but the problem seems to be with ICU, since it tells me that has_icu builds:no even though I have installed it. Do you have any idea why it can’t locate the installed ICU?
The weird thing is that I have been able to build boost for iOS some while ago after installing ICU.
I have been trying to use this on version 1.50.0 right now and have done ok. I have found that I needed to add “pch=off” to the actual build lines so that the math library will compile and that I also need to change the lines in the lipoficate function and scrunchAllLibsTogetherInOneLibPerPlatform that have filenames and add “/pch_off/” in the library path. All in all, fairly small changes.
The problem that I am having right now is that when I build the math library, boost creates four individual libs:
libboost_math_c99.a
libboost_math_c99f.a
libboost_math_tr1.a
libboost_math_tr1f.a
The build script is failing because it is looking for a single library called “libboost_math.a”. Have I done something incorrect? The boost.sh script has no reference to libboost_math_c99. I will paste the output of the build.sh script below for convenience:
BOOST_VERSION: 1_50_0
BOOST_LIBS: math
BOOST_TARBALL: /Users/justaceclutter/Downloads/Boost/boost_1_50_0.tar.bz2
BOOST_SRC: /Users/justaceclutter/Downloads/Boost/boost_1_50_0
BUILDDIR: /Users/justaceclutter/Downloads/Boost/ios/build
PREFIXDIR: /Users/justaceclutter/Downloads/Boost/ios/prefix
FRAMEWORKDIR: /Users/justaceclutter/Downloads/Boost/ios/framework
IPHONE_SDKVERSION: 5.1
XCODE_ROOT: /Applications/Xcode.app/Contents/Developer
COMPILER: clang++
Cleaning everything before we start to build…
=================================================================
Done
Invent missing headers
Bootstrapping (with libs math)
-n Building Boost.Build engine with toolset darwin…
tools/build/v2/engine/bin.macosxx86_64/b2
-n Unicode/ICU support for Boost.Regex?…
not found.
Backing up existing Boost.Build configuration in project-config.jam.11
Generating Boost.Build configuration in project-config.jam…
Bootstrapping is done. To build, run:
./b2
To adjust configuration, edit ‘project-config.jam’.
Further information:
– Command line help:
./b2 –help
– Getting started guide:
http://www.boost.org/more/getting_started/unix-variants.html
– Boost.Build documentation:
http://www.boost.org/boost-build2/doc/html/index.html
=================================================================
Done
=================================================================
Done
=================================================================
Done
Splitting all existing fat binaries…
lipo: can’t open input file: /Users/justaceclutter/Downloads/Boost/boost_1_50_0/bin.v2/libs/math/build/darwin-5.1~iphone/release/architecture-arm/link-static/macosx-version-iphone-5.1/target-os-iphone/threading-multi/libboost_math.a (No such file or directory)
lipo: can’t open input file: /Users/justaceclutter/Downloads/Boost/boost_1_50_0/bin.v2/libs/math/build/darwin-5.1~iphone/release/architecture-arm/link-static/macosx-version-iphone-5.1/target-os-iphone/threading-multi/libboost_math.a (No such file or directory)
cp: /Users/justaceclutter/Downloads/Boost/boost_1_50_0/bin.v2/libs/math/build/darwin-5.1~iphonesim/release/architecture-x86/link-static/macosx-version-iphonesim-5.1/target-os-iphone/threading-multi/libboost_math.a: No such file or directory
Decomposing each architecture’s .a files
Decomposing libboost_math.a…
ar: ../libboost_math.a: No such file or directory
ar: ../libboost_math.a: No such file or directory
ar: ../libboost_math.a: No such file or directory
Linking each architecture into an uberlib ( libboost_math.a => libboost.a )
rm: /Users/justaceclutter/Downloads/Boost/ios/build/*/libboost.a: No such file or directory
…armv6
ar: obj/*.o: No such file or directory
…armv7
ar: obj/*.o: No such file or directory
…i386
ar: obj/*.o: No such file or directory
liboficate: math
lipo: can’t open input file: /Users/justaceclutter/Downloads/Boost/boost_1_50_0/bin.v2/libs/math/build/darwin-5.1~iphone/release/architecture-arm/link-static/macosx-version-iphone-5.1/target-os-iphone/threading-multi/libboost_math.a (No such file or directory)
Aborted: Lipo math failed
I’ve run through this process multiple times and tried everything else I could think of, but I’m still not able to use the boost filesystem library in an iOS project.
Any help would be greatly appreciated.
Here are the errors I’m seeing in Xcode
[Xcode 4.4.1, Base SDK is iOS 5.1]
Undefined symbols for architecture armv7:
“vtable for boost::filesystem::detail::utf8_codecvt_facet”, referenced from:
__GLOBAL__I_a in boost(path.o)
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
There are some warnings related to the utf8 code when building the boost framework, none of which seem to me like they should cause a problem.
darwin.compile.c++ bin.v2/libs/filesystem/build/darwin-5.1~iphone/release/architecture-arm/link-static/macosx-version-iphone-5.1/target-os-iphone/threading-multi/v2/src/v2_path.oIn file included from libs/filesystem/v2/src/v2_path.cpp:34:In file included from ./boost/filesystem/detail/utf8_codecvt_facet.hpp:18:
./boost/detail/utf8_codecvt_facet.hpp:171:17: warning: ‘boost::filesystem::detail::utf8_codecvt_facet::do_length’ hides overloaded virtual function [-Woverloaded-virtual]
virtual int do_length(
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/usr/include
/c++/4.2.1/bits/codecvt.h:442:11: note: hidden overloaded virtual function ‘std::codecvt::do_length’ declared here
int do_length(state_type&, const extern_type* __from,
^
1 warning generated.
In file included from libs/filesystem/v2/src/v2_path.cpp:34:
In file included from ./boost/filesystem/detail/utf8_codecvt_facet.hpp:18:
./boost/detail/utf8_codecvt_facet.hpp:171:17: warning: ‘boost::filesystem::detail::utf8_codecvt_facet::do_length’ hides overloaded virtual function [-Woverloaded-virtual]
virtual int do_length(
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/usr/include/c++/4.2.1/bits/codecvt.h:442:11: note: hidden overloaded virtual function ‘std::codecvt::do_length’ declared here
int do_length(state_type&, const extern_type* __from,
^
1 warning generated.
hi,i have met this problem too,have you solved this? thanks!
How about building for armv7s?
in http://goodliffe.blogspot.jp/2010/09/building-boost-framework-for-ios-iphone.html
Uragawa said he manage to compile for armv7s, although I still don’t know what to do, anyone can help?
Hi vanferry, use Galbraith’s script instead (in bold at the top of my post), that will compile for armv7s.
This worked for me. I built a framework for Boost 1.52.0, using Xcode 4.5.2. The only extra work I had to do was to install the Command Line Tools, as mentioned in a comment above. Also, when trying to use the framework in a project, my coworkers and I would get linking errors related to the C++ Standard Library (std::x). We were able to resolve this by matching the project Build Settings “C++ Language Dialect” and “C++ Standard Library” with the boost.sh script file’s EXTRA_CPPFLAGS: -std=c++11 for “C++ Language Dialect” and -stdlib=libc++ for “C++ Standard Library.”
After building, how do I add this output to an .xcodeproj?
The update for the latest version of Boost and iOS 6.0 requires Boost SVN credentials. I would find it more useful if it still ran off a tar ball.
The comments over at
http://goodliffe.blogspot.co.il/2010/09/building-boost-framework-for-ios-iphone.html (referenced in Daniel’s post) are very useful also, just in case somebody hasn’t looked there.
I have just posted a useful fix to the build script here:
http://stackoverflow.com/questions/14692802/boost-threads-in-ios-thread-info-object-is-being-destructed-before-the-thread
This seems to solve a nasty bug which is actually mentioned in the boost.sh script. But the solution given there does not seem to fully work.
I keep getting this error:
Lipoing library into /Users/benkraus/galbraithjosephs-boostoniphone/ios/framework/boost.framework/Versions/A/boost...
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin//lipo: empty archive with no architecture specification: /Users/benkraus/galbraithjosephs-boostoniphone/ios/build/armv6/libboost.a (can't determine architecture for it)
Aborted: Lipo /Users/benkraus/galbraithjosephs-boostoniphone/ios/framework failed
Any ideas?
This seems to work, but I haven’t managed to use it in an actual project yet. Adding the framework leads to a bunch of errors.
I’ve also tried including the .a files in the project, but that doesn’t work either.
Any ideas?
Here are the last parts of the boost.sh output:
—————-
Splitting all existing fat binaries…
Decomposing each architecture’s .a files
Decomposing libboost_thread.a…
Decomposing libboost_signals.a…
Decomposing libboost_filesystem.a…
Decomposing libboost_regex.a…
Decomposing libboost_system.a…
Decomposing libboost_date_time.a…
Linking each architecture into an uberlib ( libboost_thread.a libboost_signals.a libboost_filesystem.a libboost_regex.a libboost_system.a libboost_date_time.a => libboost.a )
rm: /Users/matter/Documents/matterport/source/tryboost/galbraithjosephs-boostoniphone/ios/build/*/libboost.a: No such file or directory
…armv6
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ranlib: file: libboost.a(icu.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ranlib: file: libboost.a(regex_debug.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ranlib: file: libboost.a(usinstances.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ranlib: file: libboost.a(w32_regex_traits.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ranlib: file: libboost.a(windows_file_codecvt.o) has no symbols
…armv7
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ranlib: file: libboost.a(icu.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ranlib: file: libboost.a(regex_debug.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ranlib: file: libboost.a(usinstances.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ranlib: file: libboost.a(w32_regex_traits.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ranlib: file: libboost.a(windows_file_codecvt.o) has no symbols
…armv7s
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ranlib: file: libboost.a(icu.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ranlib: file: libboost.a(regex_debug.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ranlib: file: libboost.a(usinstances.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ranlib: file: libboost.a(w32_regex_traits.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ranlib: file: libboost.a(windows_file_codecvt.o) has no symbols
mac os x 10.8.2
xcode 4.5.2
BOOST_VERSION: 1_53_0
BOOST_LIBS: thread signals filesystem regex system date_time
BOOST_SRC: /Users/maksym/boost
IOSBUILDDIR: /Users/maksym/ios/build
OSXBUILDDIR: /Users/maksym/osx/build
PREFIXDIR: /Users/maksym/ios/prefix
IOSFRAMEWORKDIR: /Users/maksym/ios/framework
OSXFRAMEWORKDIR: /Users/maksym/osx/framework
IPHONE_SDKVERSION: 6.0
XCODE_ROOT: /Applications/Xcode.app/Contents/Developer
COMPILER: clang++
buildBoostForiPhoneOS()
{
cd $BOOST_SRC
# Install this one so we can copy the includes for the frameworks…
./bjam -j16 –build-dir=../iphone-build –stagedir=../iphone-build/stage –prefix=$PREFIXDIR toolset=darwin architecture=arm target-os=iphone macosx-version=iphone-${IPHONE_SDKVERSION} define=_LITTLE_ENDIAN link=static stage
…
}
I get this
sh: /Volumes/Xcode/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++: No such file or directory
sh: /Volumes/Xcode/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++: No such file or directory
/Users/maksym/boost/tools/build/v2/build/feature.jam:485: in validate-value-string from module feature
error: “iphone-6.0” is not a known value of feature
error: legal values:
…
help.
Any luck with building for armv7s that actually compile can run on iPhone5 or iPad 4gen.
I’ve tried using BoostoniPhone and a-coding still no luck!!
Sorry to hear that – Galbraith’s script worked for me, with the exception of what Jason said above. My project runs on iPhone 5 and iPad 4. What problem are you having specifically?
I can only build libraries named below (with 1.53.0) using this script here: https://github.com/wuhao5/boost/blob/188e905626dbd522f65950102ed0c8ce77cb28e8/boost.sh
– atomic
– chrono
– context
– date_time
– exception
– filesystem
– graph
– graph_parallel
– iostreams
– locale
– math
– mpi
– program_options
– python
– random
– regex
– serialization
– signals
– system
– test
– thread
– timer
– wave
Anyone has a clue why i can’t do it for libraries like “property_tree”?
Somewhere in the script I am encountering
“error: wrong library name ‘property_tree’ in the –with- option.”