compile Boost as static Universal binary lib

↘锁芯ラ 提交于 2019-11-30 07:36:42
Albert

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!