11

I have a problem building Boost for Xcode 5 now that there is only one compiler LLVM 5.0.

I've tried with Homebrew using --c++11, using clang.... I've tried various ideas and scripts but none has worked so far.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Metodij Zdravkin
  • 914
  • 1
  • 14
  • 23
  • Have you seen `boost.sh` in this SO question? http://stackoverflow.com/questions/17714635/how-can-i-compile-boost-1-54-0-1-54-for-the-ios-simulator-6-1-on-os-x-10-8-4 – trojanfoe Sep 19 '13 at 08:19
  • No I haven't seen this one... even though I search for 3 days. Will give it a try – Metodij Zdravkin Sep 19 '13 at 08:29
  • I used the super secret magic word sequence "building boost for ios" ;-) – trojanfoe Sep 19 '13 at 08:30
  • The link is useful but not for XCode 5. It uses darwin and the latest XCode works only with Clang. Thanks – Metodij Zdravkin Sep 19 '13 at 08:39
  • I've just downloaded `boost.sh` and it built the iOS version of the library without problem (Xcode 5 DP 6 on OSX 10.8). It failed to build for iphone simulator, but that is issue from the question I linked to. – trojanfoe Sep 19 '13 at 08:48

1 Answers1

23

To build 32/64 bit fat static binaries for boost 1.54.0 compiled with clang/llvm, the only compiler for Xcode 5:

  1. Download the unix tarball (not the ZIP! -- that has CR/LF line endings and will gack)
  2. Untar it.
  3. cd to boost_1_54_0/
  4. Run:

    ./bootstrap.sh toolset=clang

  5. Run:

    ./b2 toolset=clang --without-mpi cxxflags="-arch i386 -arch x86_64 -fvisibility=hidden -fvisibility-inlines-hidden -std=c++11 -stdlib=libc++ -ftemplate-depth=512" linkflags="-stdlib=libc++" link=static stage

...which puts the output libs in ./stage/lib

Then move the libraries where you want them.

These are release libraries, which should be all you need.

This is for OSX. You can change -arch and add other options in the cxxflags= for iOS.

If you need the message passing interface, remove --without-mpi from the b2 command.

==== Fun Facts:

  • building boost seems a moving target, so these instructions will likeley break in a future release
  • I tried to -Wno-xxxx the warnings off in the cxxflags= ... but it didn't work
  • bjam and b2 are the same thing, b2 is the new name
  • clang as a first-class toolset was added somewhere along the way, so you can ignore any instructions on the web to modify "user-config.jam" (Everything you need seems to be able to be passed on the b2 command line for these one-off builds.)
Sebastian
  • 8,046
  • 2
  • 34
  • 58
PatchyFog
  • 1,551
  • 16
  • 17
  • Thanks for sharing. This is actually how we do it, put all flags in cxx flags and it works perfect. Too bad brew was not working at the time, I am not sure maybe they have update for clang 5.0. Also, your note is right this works with Boost 1.54, I had some problems with 1.49. Right Answer for questions, thanks! – Metodij Zdravkin Sep 29 '13 at 17:49
  • it says "x86: yes", "32-bit: no", "64-bit: no". It is actually compiling with 64 bit support? I entered it exactly the way you had it. – stewart99 Dec 23 '13 at 08:09
  • And what about arm7 and arm7s? Can you please help me and type here the whole command which I have to execute to make the lib run on an device? – pawel.kalisz Jan 09 '14 at 09:55
  • @pawel.kalisz were you able to find the command for doing it on android devices ? – Amit Hooda Mar 18 '14 at 14:45
  • Actually for me it was just switch from libc++ to libstd++ in project settings and all problems disappeared. – pawel.kalisz Mar 18 '14 at 21:06