在 CentOS 上设置默认 g++?

在 CentOS 上设置默认 g++?

我正在尝试将默认的 g++ 设置为 4.7.2,我的主机告诉我已安装该版本(我还被告知还安装了 c++11);然而,我们都不知道如何将默认的 g++ 设置为 4.7.2,因为g++ --version给出了

g++ (GCC) 4.1.2 20080704 (Red Hat 4.1.2-54)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

sudo在这里尝试了这些命令,但我刚刚发现它们不起作用,因为 CentOS 使用yum.

如何在 CentOS 5.9 上将默认 g++ 设置为 4.7.2(如果已安装)?

答案1

您需要设置CXX环境变​​量。例如,export CXX="/usr/bin/g++-4.7"。而CC就是控制C编译器的。

相关内容