C++ 如何在 MacOS 上安装 Boost?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/104322/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 12:52:21  来源:igfitidea点击:

How do you install Boost on MacOS?

c++macosboost

提问by Robert Gould

How do you install Boost on MacOS? Right now I can't find bjam for the Mac.

如何在 MacOS 上安装 Boost?现在我找不到适用于 Mac 的 bjam。

采纳答案by dies

Download MacPorts, and run the following command:

下载MacPorts,并运行以下命令:

sudo port install boost 

回答by jrwren

You can get the latest version of Boost by using Homebrew.

您可以使用Homebrew获取最新版本的 Boost 。

brew install boost.

brew install boost.

http://brewformulas.org/Boost

http://brewformulas.org/Boost

回答by snies

Just get the source, and compile Boost yourself; it has become very easy. Here is an example for the current version of Boost on the current macOS as of this writing:

只需获取源代码,然后自己编译 Boost;它变得非常容易。以下是撰写本文时当前 macOS 上当前版本的 Boost 的示例:

  1. Download the the .tar.gz from https://www.boost.org/users/download/#live
  2. Unpack and go into the directory:

    tar -xzf boost_1_50_0.tar.gz
    cd boost_1_50_0

  3. Configure (and build bjam):

    ./bootstrap.sh --prefix=/some/dir/you/would/like/to/prefix
  4. Build:

    ./b2
  5. Install:

    ./b2 install

  1. https://www.boost.org/users/download/#live下载 .tar.gz
  2. 解压并进入目录:

    tar -xzf boost_1_50_0.tar.gz
    cd boost_1_50_0

  3. 配置(和构建bjam):

    ./bootstrap.sh --prefix=/some/dir/you/would/like/to/prefix
  4. 建造:

    ./b2
  5. 安装:

    ./b2 install

Depending on the prefix you choose in Step 3, you might need to sudo Step 5, if the script tries copy files to a protected location.

根据您在步骤 3 中选择的前缀,如果脚本尝试将文件复制到受保护的位置,您可能需要 sudo 步骤 5。

回答by snies

Unless your compiler is different than the one supplied with the Mac XCode Dev tools, just follow the instructions in section 5.1 of Getting Started Guide for Unix Variants. The configuration and building of the latest source couldn't be easier, and it took all about about 1 minute to configure and 10 minutes to compile.

除非您的编译器与 Mac XCode 开发工具提供的编译器不同,否则只需按照Unix 变体入门指南5.1 节中的说明进行操作。最新源代码的配置和构建再简单不过了,配置大约需要 1 分钟,编译大约需要 10 分钟。

回答by dmckee --- ex-moderator kitten

Finkappears to have a full set of Boost packages...

Fink似乎有一套完整的 Boost 包...

With fink installed and running just do

安装并运行 fink 就可以了

fink install boost1.35.nopython

at the terminal and accept the dependencies it insists on. Or use

在终端并接受它坚持的依赖关系。或使用

fink list boost

to get a list of different packages that are availible.

获取可用的不同软件包的列表。

回答by Kondal Rao

Install both of them using homebrew separately.

分别使用自制软件安装它们。

brew install boost
brew install bjam

brew安装boost
brew安装bjam

回答by UDAY JAIN

Install Xcode from the mac app store. Then use the command:

从 Mac 应用商店安装 Xcode。然后使用命令:

  /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

the above will install homebrew and allow you to use brew in terminal

以上将安装自制软件并允许您在终端中使用 brew

then just use command :

然后只需使用命令:

brew install boost

which would then install the boost libraries to <your macusername>/usr/local/Cellar/boost

然后将boost库安装到 <your macusername>/usr/local/Cellar/boost

回答by Hymansonkr

Try +universal

尝试 +universal

One thing to note: in order for that to make a difference you need to have built pythonwith +universal, if you haven't or you're not sure you can just rebuild python +universal. This applies to both brewas well as macports.

有一点需要注意:为了让该有所作为,你需要有内置python+universal,如果你没有,或者你不知道你可以重建python +universal。这适用于brewmacports

$ brew reinstall python
$ brew install boost

OR

或者

$ sudo port -f uninstall python
$ sudo port install python +universal
$ sudo port install boost +universal

回答by user1823890

In order to avoid troubles compiling third party libraries that need boost installed in your system, run this:

为了避免编译需要在系统中安装 boost 的第三方库的麻烦,请运行以下命令:

sudo port install boost +universal

回答by Ferruccio

you can download bjam for OSX (or any other OS) here

您可以在此处下载适用于 OSX(或任何其他操作系统)的 bjam