简体   繁体   English

如何告诉超级计算机上的C ++编译器我的R包需要C ++ 0x?

[英]How do I tell the C++ compiler on a supercomputer that my R package requires C++0x?

I have written and built an R package that depends on Rcpp and requires the C++0x standard (for using the tgamma function in C++). 我已经写和内置的R包取决于Rcpp和要求C++0x标准(用于使用tgamma函数在C ++)。 I have tested the package on various desktop computers and operating systems, and it always seems to install and work fine. 我已经在各种台式计算机和操作系统上测试了软件包,它似乎总是安装并正常工作。 However, I would also like to use the package on an HPC server. 但是,我还想在HPC服务器上使用该软件包。 When I try to install the package there in my local R library tree using R CMD INSTALL test (where test is the name of the package), I get the following error message from the compiler: 当我尝试使用R CMD INSTALL test (其中test是包的名称)在我的本地R库树中R CMD INSTALL test包时,我从编译器收到以下错误消息:

/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. /usr/include/c++/4.4.7/c++0x_warning.h(31):灾难性错误:#error指令:此文件需要编译器和库支持即将推出的ISO C ++标准C ++ 0x。 This support is currently experimental, and must be enabled with the -std=c++0x or -std=gnu++0x compiler options. 此支持目前是实验性的,必须使用-std = c ++ 0x或-std = gnu ++ 0x编译器选项启用。 #error This file requires compiler and library support for the upcoming \\ ^ #error此文件需要编译器和库支持即将到来的\\ ^

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' 编译中止Metropolis_Sampler_Beta_Edgewise_Cpp_Statistics.cpp(代码4)make:*** [Metropolis_Sampler_Beta_Edgewise_Cpp_Statistics.o]错误4错误:包'test'的编译失败

It basically tells me that I should enable C++0x support when the compiler is called (as in this post). 它基本上告诉我在调用编译器时应该启用C ++ 0x支持(如本文所述 )。 Yet, I thought adding the statement CXX_STD = CXX11 to the src/Makevars file in the R package would actually tell the compiler that this version needs to be used. 然而,我认为将语句CXX_STD = CXX11添加到R包中的src/Makevars文件实际上会告诉编译器需要使用此版本。 And indeed that seems to be the case on various desktop computers I have tried. 事实上,在我尝试的各种台式电脑上似乎就是这种情况。 So my question is: how can I tell the compiler on the server that this C++ version should be used for compilation? 所以我的问题是:如何告诉服务器上的编译器这个C ++版本应该用于编译? Alternatively, how else can I install the package? 或者,我怎么能安装包?

On the server, I load the module for R by entering module load math/R on the terminal before trying to install the package, and it reports back that the following modules were loaded: 在服务器上,我通过在尝试安装软件包之前在终端上输入module load math/Rmodule load math/R R module load math/R ,并报告已加载以下模块:

Loading module dependency 'compiler/intel/13.1'. 加载模块依赖'compiler / intel / 13.1'。

Loading module dependency 'numlib/mkl/11.0.5'. 加载模块依赖项'numlib / mkl / 11.0.5'。

Edit 1 : The server is a German university cluster called bwUniCluster. 编辑1 :服务器是名为bwUniCluster的德国大学集群。 It is based on KITE 2.0/RHEL6.5/Lustre 2.5.2. 它基于KITE 2.0 / RHEL6.5 / Lustre 2.5.2。 As far as I can tell from the module message reported above, it seems to be the Intel C++ Compiler XE (ICPC) version 13.1.3. 据我所知,从上面报告的模块消息来看,它似乎是英特尔C ++编译器XE(ICPC)版本13.1.3。 But actually I have no clue about compilers, so if you need to know anything more specific, please let me know. 但实际上我对编译器一无所知,所以如果你需要了解更具体的内容,请告诉我。

Edit 2 It's also possible to execute module load compiler/gnu/4.9 on the terminal before I try to install the package. 编辑2在尝试安装软件包之前,还可以在终端上执行module load compiler/gnu/4.9 This results in the following error message (similar as the one above), which leads me to think that this is not a version problem: 这会导致以下错误消息(类似于上面的错误消息),这使我认为这不是版本问题:

/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. /pfs/data1/software_uc1/bwhpc/common/compiler/gnu/4.9.2/bin/../include/c++/4.9.2/bits/c++0x_warning.h(32):灾难性错误:#error指令:此文件需要ISO C ++ 2011标准的编译器和库支持。 This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options. 此支持目前是实验性的,必须使用-std = c ++ 11或-std = gnu ++ 11编译器选项启用。 #error This file requires compiler and library support for the \\ ^ #error此文件需要对\\ ^的编译器和库支持

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' 编译中止Metropolis_Sampler_Beta_Edgewise_Cpp_Statistics.cpp(代码4)make:*** [Metropolis_Sampler_Beta_Edgewise_Cpp_Statistics.o]错误4错误:包'test'的编译失败

Edit 3 : One of the comments suggests that both the R package and R itself need to be compiled using the same compiler version. 编辑3 :其中一条评论表明R包和R本身都需要使用相同的编译器版本进行编译。 Is this correct? 这个对吗? R was built using g++ 4.4.7 on this machine. R是在这台机器上使用g ++ 4.4.7构建的。 Does this mean that the only feasible solution is to convince the sys admin to recompile R with the other 4.9.2 compiler and provide it as a new module? 这是否意味着唯一可行的解​​决方案是说服系统管理员使用其他4.9.2编译器重新编译R并将其作为新模块提供? I find this hard to believe, given the following sentence in the " Writing R Extensions " manual: 考虑到“ Writing R Extensions ”手册中的以下句子,我觉得很难相信:

On these platforms, it is necessary to select a different compiler for C++11, via personal or site Makevars files. 在这些平台上,有必要通过个人或站点Makevars文件为C ++ 11选择不同的编译器。

The solution was indeed to recompile R on the server with a newer compiler, in this case Intel 14 (as discussed in Edit 3 in the original post). 解决方案确实是使用更新的编译器在服务器上重新编译R,在本例中为Intel 14(如原始帖子中的编辑3中所述)。 The sys admin was so kind to set up a new module for this R version. 系统管理员非常友好地为这个R版本设置了一个新模块。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM