使用 gcc4.7 标准库与英特尔 12.1.3 一起编译

Compile with Intel 12.1.3 using gcc4.7 std library

本文关键字:一起 编译 英特尔 gcc4 标准 使用      更新时间:2023-10-16

我遇到了这篇文章中描述的相同问题,只是我使用的是英特尔版本 12.1.3。(g++ 的标头<functional>#ifdef __GXX_EXPERIMENTAL_CXX0X__ 保护,而使用 ICPC 时未定义该

标头。

与其使用 boost::functional,我想安装 gcc4.7 并使用它的 std 库。

在 Ubuntu 11.10 中,我有gcc4.6.1,但我也从gcc-snapshot包中安装了gcc4.7

英特尔有 -gcc-name-gxx-name-cxxlib 选项。所以最初我编译的是:

-std=c++0x -gcc-name=/usr/lib/gcc-snapshot/bin/gcc -gxx-name=/usr/lib/gcc-snapshot/bin/g++ -cxxlib=/usr/lib/gcc-snapshot/

但我收到错误:

icpc: error #10282: file '/usr/lib/gcc-snapshot/bin/usr/lib/gcc-snapshot/bin/g++' not found, generated based on '-cxxlib=/usr/lib/gcc-snapshot/'

然后我编译为:

-std=c++0x -gcc-name=./gcc -gxx-name=./g++ -cxxlib=/usr/lib/gcc-snapshot/ .

但我仍然收到警告和错误:

Warning #2928: the __GXX_EXPERIMENTAL_CXX0X__ macro is disabled when using GNU version 4.6 with the c++0x option

error: namespace "std" has no member "function"

警告清楚地表明它仍在使用版本 4.6。有谁知道如何让英特尔使用正确的库?

我发现,如果你使用 gcc(或 g++)和标志 -v -Q 编译,你会得到一个标志列表并定义。 它可能会帮助您了解 gcc 的作用,因此您可以在 icpc 中使用相同的 -D/-U。 此外,g++ -E 将在不编译的情况下进行预处理:您可以从中获得有用的路径信息。