views:

428

answers:

2

I want to have a static Universal binary lib of Boost. (Preferable the latest stable version, that is 1.43.0, or newer.)

I found many Google hits with similar problems and possible solutions. However, most of them seems outdated. Also none of them really worked.

Right now, I am trying

sudo ./bjam --toolset=darwin --link=static --threading=multi \
--architecture=combined --address-model=32_64 \
--macosx-version=10.4 --macosx-version-min=10.4 \
install

That compiles and install fine. However, the produced binaries seems broken.

az@ip245 47 (openlierox) %file /usr/local/lib/libboost_signals.a
/usr/local/lib/libboost_signals.a: current ar archive random library

az@ip245 49 (openlierox) %lipo -info  /usr/local/lib/libboost_signals.a
input file /usr/local/lib/libboost_signals.a is not a fat file
Non-fat file: /usr/local/lib/libboost_signals.a is architecture: x86_64

Edit: It seems that the command was wrong and I must remove the "--" for most options. So the command I am trying now (-a just means to rebuild all):

sudo ./bjam -a toolset=darwin link=static threading=multi \
architecture=combined address-model=32_64 \
macosx-version=10.4 macosx-version-min=10.4 \
install

However, this gives many strange errors (what I already had earlier), all like this:

darwin.compile.c++.pch bin.v2/libs/math/build/darwin-4.2.1/release/address-model-32_64/architecture-combined/link-static/macosx-version-min-10.4/macosx-version-10.4/threading-multi/../src/tr1/pch.hpp.gch
In file included from ./boost/math/special_functions/acosh.hpp:18,
                 from ./boost/math/special_functions.hpp:15,
                 from libs/math/build/../src/tr1/pch.hpp:9:
./boost/config/no_tr1/cmath.hpp:21:19: error: cmath: No such file or directory

This could be another problem I have when building Universal binaries: http://stackoverflow.com/questions/2830931/g-on-macosx-doesnt-work-with-arch-ppc64

+2  A: 

I found the problem. It seems that the MacOSX 10.4 SDK is missing a bunch of symlinks for GCC 4.2.

Use this as a test case: http://stackoverflow.com/questions/2830931/g-on-macosx-doesnt-work-with-arch-ppc64

It will report multiple errors with GCC 4.2 (missing C++ includes, missing C includes, missing libs). In all cases, you can just fix that by setting a symlink. Search in your SDK for the file and just set the symlink in the same way it is in the MacOSX 10.5 SDK.

After that, it all just worked.

Albert
+1  A: 

We use Boost compiled for 10.4 here at work. We don't use GCC 4.2 on it though, rather we use GCC 4.0 as Apple's GCC 4.2 is not supported for the MacOS 10.4 SDK. To accomplish this you need a bjam user config file, eg. user-config-darwin.jam. Here's the contents of ours. Modify to your heart's content:

# Boost.Build Configuration

    # Compiler configuration
using darwin : 8.11 : /usr/bin/g++-4.0 : 
    <architecture>"combined"
    <address-model>"32" # this can be changed to 32_64 for 32/64 universal builds
    <macosx-version>"10.4"
    <macosx-version-min>"10.4"
#   <root>"/Developer"
    <compileflags>""
    <linkflags>"" ; 

Then, you need to tell bjam to use the user config jam file when compiling:

bjam --user-config=user-config-darwin.jam ... (your other options go here) ...

Now you don't have to mess with symlinks in the system SDK directories.

Grant Limberg
See my answer. The fix to make it working with GCC 4.2 was rather easy. And works just fine. But thank you anyway for the information, this may still be usefull for me at some later time.
Albert