我如何告诉超级计算机上的 C++ 编译器我的 R 包需要 C++0x?
How do I tell the C++ compiler on a supercomputer that my R package requires C++0x?
我已经编写并构建了一个依赖于 Rcpp
并需要 C++0x
标准(用于在 C++ 中使用 tgamma
函数)的 R 包。我已经在各种台式电脑和操作系统上测试过这个包,它似乎总是安装和工作正常。但是,我也想在 HPC 服务器上使用该包。当我尝试使用 R CMD INSTALL test
(其中 test
是包的名称)在本地 R 库树中安装包时,我从编译器收到以下错误消息:
/usr/include/c++/4.4.7/c++0x_warning.h(31): catastrophic error: #error directive: This file requires compiler and library support for the upcoming ISO C++ standard, C++0x. This support is currently experimental, and must be enabled with the -std=c++0x or -std=gnu++0x compiler options.
#error This file requires compiler and library support for the upcoming \
^
compilation aborted for Metropolis_Sampler_Beta_Edgewise_Cpp_Statistics.cpp (code 4)
make: *** [Metropolis_Sampler_Beta_Edgewise_Cpp_Statistics.o] Error 4
ERROR: compilation failed for package ‘test’
它基本上告诉我应该在调用编译器时启用 C++0x 支持(如 this post)。然而,我认为将语句 CXX_STD = CXX11
添加到 R 包中的 src/Makevars
文件实际上会告诉编译器需要使用此版本。事实上,在我试过的各种台式电脑上似乎都是这种情况。所以我的问题是:如何告诉服务器上的编译器应该使用这个 C++ 版本进行编译?或者,我还能如何安装该软件包?
在服务器上,我在尝试安装包之前通过在终端上输入 module load math/R
来加载 R 的模块,它报告已加载以下模块:
Loading module dependency 'compiler/intel/13.1'.
Loading module dependency 'numlib/mkl/11.0.5'.
编辑 1:服务器是一个名为 bwUniCluster 的德国大学集群。它基于 KITE 2.0/RHEL6.5/Lustre 2.5.2。据我从上面报告的模块消息可以看出,它似乎是 Intel C++ Compiler XE (ICPC) 版本 13.1.3。但实际上我对编译器一无所知,所以如果您需要了解更具体的信息,请告诉我。
编辑 2 在我尝试安装软件包之前,也可以在终端上执行 module load compiler/gnu/4.9
。这导致以下错误消息(与上面的错误消息类似),这让我认为这不是版本问题:
/pfs/data1/software_uc1/bwhpc/common/compiler/gnu/4.9.2/bin/../include/c++/4.9.2/bits/c++0x_warning.h(32): catastrophic error: #error directive: This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support for the \
^
compilation aborted for Metropolis_Sampler_Beta_Edgewise_Cpp_Statistics.cpp (code 4)
make: *** [Metropolis_Sampler_Beta_Edgewise_Cpp_Statistics.o] Error 4
ERROR: compilation failed for package ‘test’
编辑 3:其中一条评论建议 R 包和 R 本身都需要使用相同的编译器版本进行编译。这个对吗? R 是在本机上使用 g++ 4.4.7 构建的。这是否意味着唯一可行的解决方案是说服系统管理员使用其他 4.9.2 编译器重新编译 R 并将其作为新模块提供?鉴于“Writing R Extensions”手册中的以下句子,我发现这很难相信:
On these platforms, it is necessary to select a different compiler for C++11, via personal or site Makevars files.
解决方案确实是在服务器上使用更新的编译器重新编译 R,在本例中为 Intel 14(如原始 post 中的编辑 3 中所讨论)。系统管理员非常友好地为此 R 版本设置了一个新模块。
我已经编写并构建了一个依赖于 Rcpp
并需要 C++0x
标准(用于在 C++ 中使用 tgamma
函数)的 R 包。我已经在各种台式电脑和操作系统上测试过这个包,它似乎总是安装和工作正常。但是,我也想在 HPC 服务器上使用该包。当我尝试使用 R CMD INSTALL test
(其中 test
是包的名称)在本地 R 库树中安装包时,我从编译器收到以下错误消息:
/usr/include/c++/4.4.7/c++0x_warning.h(31): catastrophic error: #error directive: This file requires compiler and library support for the upcoming ISO C++ standard, C++0x. This support is currently experimental, and must be enabled with the -std=c++0x or -std=gnu++0x compiler options. #error This file requires compiler and library support for the upcoming \ ^
compilation aborted for Metropolis_Sampler_Beta_Edgewise_Cpp_Statistics.cpp (code 4) make: *** [Metropolis_Sampler_Beta_Edgewise_Cpp_Statistics.o] Error 4 ERROR: compilation failed for package ‘test’
它基本上告诉我应该在调用编译器时启用 C++0x 支持(如 this post)。然而,我认为将语句 CXX_STD = CXX11
添加到 R 包中的 src/Makevars
文件实际上会告诉编译器需要使用此版本。事实上,在我试过的各种台式电脑上似乎都是这种情况。所以我的问题是:如何告诉服务器上的编译器应该使用这个 C++ 版本进行编译?或者,我还能如何安装该软件包?
在服务器上,我在尝试安装包之前通过在终端上输入 module load math/R
来加载 R 的模块,它报告已加载以下模块:
Loading module dependency 'compiler/intel/13.1'.
Loading module dependency 'numlib/mkl/11.0.5'.
编辑 1:服务器是一个名为 bwUniCluster 的德国大学集群。它基于 KITE 2.0/RHEL6.5/Lustre 2.5.2。据我从上面报告的模块消息可以看出,它似乎是 Intel C++ Compiler XE (ICPC) 版本 13.1.3。但实际上我对编译器一无所知,所以如果您需要了解更具体的信息,请告诉我。
编辑 2 在我尝试安装软件包之前,也可以在终端上执行 module load compiler/gnu/4.9
。这导致以下错误消息(与上面的错误消息类似),这让我认为这不是版本问题:
/pfs/data1/software_uc1/bwhpc/common/compiler/gnu/4.9.2/bin/../include/c++/4.9.2/bits/c++0x_warning.h(32): catastrophic error: #error directive: This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options. #error This file requires compiler and library support for the \ ^
compilation aborted for Metropolis_Sampler_Beta_Edgewise_Cpp_Statistics.cpp (code 4) make: *** [Metropolis_Sampler_Beta_Edgewise_Cpp_Statistics.o] Error 4 ERROR: compilation failed for package ‘test’
编辑 3:其中一条评论建议 R 包和 R 本身都需要使用相同的编译器版本进行编译。这个对吗? R 是在本机上使用 g++ 4.4.7 构建的。这是否意味着唯一可行的解决方案是说服系统管理员使用其他 4.9.2 编译器重新编译 R 并将其作为新模块提供?鉴于“Writing R Extensions”手册中的以下句子,我发现这很难相信:
On these platforms, it is necessary to select a different compiler for C++11, via personal or site Makevars files.
解决方案确实是在服务器上使用更新的编译器重新编译 R,在本例中为 Intel 14(如原始 post 中的编辑 3 中所讨论)。系统管理员非常友好地为此 R 版本设置了一个新模块。