将 Boost 编译为静态通用二进制库

发布于 2024-09-01 07:21:06 字数 1688 浏览 4 评论 0原文

我想要一个 Boost 的静态通用二进制库。 (最好是最新的稳定版本,即 1.43.0 或更高版本。)

我发现许多 Google 搜索结果都有类似的问题和可能的解决方案。然而,其中大多数似乎已经过时了。而且它们都没有真正起作用。

现在,我正在尝试

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

编译和安装良好。然而,生成的二进制文件似乎已损坏。

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

编辑:看来命令是错误的,我必须删除大多数选项的“--”。所以我现在尝试的命令(-a 只是意味着重建所有):

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

但是,这会产生许多奇怪的错误(我之前已经遇到过),都是这样的:

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

这可能是我在构建通用二进制文件时遇到的另一个问题:MacOSX 上的 g++ 不适用于 -arch ppc64

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

月野兔 2024-09-08 07:21:14

要在 OSX 10.6 上构建 4 路通用 boost 静态二进制文件,我执行以下操作:

  1. 从 boost 网站下载 boost。

  2. 将存档和 cd 解压到 boost_1_xx_0 文件夹(其中 xx 是您正在使用的 boost 版本)。

  3. 运行:

    ./bootstrap.sh 然后

    ./bjam macosx-version=10.6 macosx-version-min=10.4 Architecture=combined threading=multi link=static address-model=32_64

这将编译除以下内容之外的所有内容对于 Boost.MPI(需要 --with-mpi 选项)。构建产品放入 ./stage

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

最偏执的依靠 2024-09-08 07:21:13

我们在工作中使用为 10.4 编译的 Boost。不过,我们不使用 GCC 4.2,而是使用 GCC 4.0,因为 MacOS 10.4 SDK 不支持 Apple 的 GCC 4.2。要实现此目的,您需要一个 bjam 用户配置文件,例如。用户配置-darwin.jam。这是我们的内容。随心所欲地修改:

# 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>"" ; 

然后,您需要告诉 bjam 在编译时使用用户配置 jam 文件:

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

现在您不必弄乱系统 SDK 目录中的符号链接。

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.

音盲 2024-09-08 07:21:11

我发现了问题。 MacOSX 10.4 SDK 似乎缺少一堆 GCC 4.2 的符号链接。

将此用作测试用例:
MacOSX 上的 g++ 不适用于 -arch ppc64

将报告 GCC 4.2 的多个错误(缺少 C++ 包含、缺少 C 包含、缺少库)。在所有情况下,您都可以通过设置符号链接来解决该问题。在 SDK 中搜索该文件,然后按照与 MacOSX 10.5 SDK 中相同的方式设置符号链接。

在那之后,一切都顺利了。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文