开发者

compile Boost as static Universal binary lib

开发者 https://www.devze.com 2022-12-30 09:12 出处:网络
I want to have a static Universal binary lib of Boost. (Preferable the latest stable version, that is 1.43.0, or newer.)

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 se开发者_StackOverflowems 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: g++ on MacOSX doesn't work with -arch ppc64


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: g++ on MacOSX doesn't 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.


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.


To build 4-way universal boost static binaries on OSX 10.6 I do the following:

  1. Download boost from the boost website.

  2. Extract the archive and cd into the boost_1_xx_0 folder (where xx is the version of boost you are using).

  3. Run:

    ./bootstrap.sh and then

    ./bjam 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

0

精彩评论

暂无评论...
验证码 换一张
取 消