指定编译器 Homebrew 安装

Specify compiler Homebrew install

我在 OSX 10.8

上尝试安装 mkvtoolnixhomebrew 时遇到了障碍

当我尝试 brew install mkvtoolnix 时,我得到以下错误跟踪

checking for support for C++11 feature "nullptr"... yes
checking for support for C++11 feature "tuples"... yes
checking for support for C++11 feature "alias declarations"... yes
checking for support for C++14 feature "std::make_unique"... no
checking for support for C++14 feature "digit separators"... no
checking for support for C++14 feature "binary literals"... no
checking for support for C++14 feature "generic lambdas"... no
The following features of the C++11/C++14 standards are not supported by clang++:
  * std::make_unique function (C++14)
  * digit separators (C++14)
  * binary literals (C++14)
  * generic lambdas (C++14)
If you are using the GNU C compiler collection (gcc) then you need
at least v4.9.x.
configure: error: support for required C++11/C++14 features incomplete

这是有道理的,因为 clang++ 不支持 C++14 功能。此外,我已经安装了 GCC 5.2,因此可以使用 g++-5.2.0 来编译它们。

问题是我还没有看到在调用 brew install

时设置不同的编译器

我已经尝试将 ccc++gccg++ 添加到路径并将它们符号链接到 usr/local/binusr/bin无济于事,总是求助于clang++

如何指定 g++-5.2.0 作为编译器?

您需要在安装命令中添加一个选项:

brew install --cc=gcc-5.2 mkvtoolnix

注意只允许使用有限的编译器列表(自制编译器)。您还应该检查是否安装了 gcc-5.2:

which gcc-5.2

对于较新版本的 Homebrew,它现在支持使用 HOMEBREW_CCHOMEBREW_CXX 环境变量。有关详细信息,请参阅 this SO post