问题
How to build boost 1.45 universal binaries? on leopard/ snow leopard ?
回答1:
To build 4-way universal boost static binaries on OSX 10.6 I do the following:
Download boost from the boost website.
Extract the archive and
cd
into theboost_x_xx_x
folder (wherex_xx_x
is the version of boost you are using).Run:
./bootstrap.sh
and then# The name of the Boost.Jam program changed from "bjam" to "b2" in Boost 1.47.0
# Replace "b2" with "bjam" if you are compiling a version <= 1.46.1
./b2 macosx-version=10.6 macosx-version-min=10.4 architecture=combined threading=multi link=static address-model=32_64
This will compile everything except for Boost.MPI (which requires the --with-mpi
option). The build products get put in ./stage
UPDATE: If you have installed XCode 4, then there is an extra step that you must perform. XCode 4 does not come with compilers or libraries capable of targeting PowerPC. Unfortunately, the compilers that come with XCode 4 become the default compilers used by Boost. To force the use of the compilers that come with XCode 3, you must perform an extra step. Note that you must install XCode 3 if it is not on your system.
After running ./bootstrap.sh
, and before running b2
, open:
./tools/build/v2/user-config.jam
Add following line to that file. This instructs boost to use the g++-4.2 from XCode 3:
using darwin : : /Developer-old/usr/bin/g++-4.2 ;
回答2:
Which libraries are you trying to build? It says here (http://www.boost.org/doc/libs/1_45_0/more/getting_started/unix-variants.html) that:
Most Boost libraries are header-only: they consist entirely of header files containing templates and inline functions, and require no separately-compiled library binaries or special treatment when linking.
The one that you do need to build are:
- Boost.Filesystem
- Boost.GraphParallel
- Boost.IOStreams
- Boost.MPI
- Boost.ProgramOptions
- Boost.Python
- Boost.Regex
- Boost.Serialization
- Boost.Signals
- Boost.System
- Boost.Thread
- Boost.Wave
So which one are you trying to build?
回答3:
To build universal binaries under Tiger I was creating user-config.jam file in my home directory ($HOME
):
using darwin : : : <compileflags>"-arch ppc -arch i386 -mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk" ;
And then I was building Boost as usual with Jam. Probably this should still work with older Mac OS X versions.
Another way is to use MacPorts but in this case all Boost dependencies have to be rebuilt as universal binaries which is not always possible (I've this on Tiger for two times but failed).
For both cases you need to have MacOSX10.4u.sdk installed with XCode.
[edit]
To build for three architectures you'd better read an answer to a similar question. Briefly, build options in user-config.jam
depend on your and target Mac OS X versions. So you'd better try various variants based on the aforementioned answer.
来源:https://stackoverflow.com/questions/4755712/how-to-build-boost-1-45-universal-binaries