致命错误:auc_.cpp:2:10:致命错误:omp.h:没有此类文件或目录

时间:2019-04-10 18:44:16

标签: c++ r amazon-web-services compiler-errors

我正在AWS的Linux机器上运行RServer Studio。

我试图安装ModelMetrics的依赖项caret,并收到此错误:

auc_.cpp:2:10: fatal error: omp.h: No such file or directory
 #include <omp.h>
          ^~~~~~~
compilation terminated.
make: *** [auc_.o] Error 1
ERROR: compilation failed for package ‘ModelMetrics’

这是完整的输出消息

Installing package into ‘/home/User/R/x86_64-pc-linux-gnu-library/3.5’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/ModelMetrics_1.2.2.tar.gz'
Content type 'application/x-gzip' length 16974 bytes (16 KB)
==================================================
downloaded 16 KB

* installing *source* package ‘ModelMetrics’ ...
** package ‘ModelMetrics’ successfully unpacked and MD5 sums checked
** libs
g++  -I"/opt/R/3.5.3/lib64/R/include" -DNDEBUG  -I"/home/User/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -I/usr/local/include   -fpic  -g -O2  -c RcppExports.cpp -o RcppExports.o
g++  -I"/opt/R/3.5.3/lib64/R/include" -DNDEBUG  -I"/home/User/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -I/usr/local/include   -fpic  -g -O2  -c auc_.cpp -o auc_.o
auc_.cpp:2:10: fatal error: omp.h: No such file or directory
 #include <omp.h>
          ^~~~~~~
compilation terminated.
make: *** [auc_.o] Error 1
ERROR: compilation failed for package ‘ModelMetrics’
* removing ‘/home/User/R/x86_64-pc-linux-gnu-library/3.5/ModelMetrics’
Warning in install.packages :
  installation of package ‘ModelMetrics’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/Rtmpr06k8i/downloaded_packages’

我环顾四周,看起来编译器有错误。我尝试了here列出的解决方案,特别是我运行了这些命令

yum groupinstall 'Development Tools'
mkdir ~/.R
echo "CC=gcc64" >> ~/.R/Makevars
sudo sed -i 's/CC = gcc -m64/CC = gcc64 -m64/g' /usr/lib64/R/etc/Makeconf

即使重新启动RStudio服务器之后,我也会得到相同的输出和错误消息。

该错误看起来与problem here非常相似。遵循这些说明后,我仍然没有解决方案,但是我确实找到了omp.h文件的位置。

/usr/lib/gcc/x86_64-amazon-linux/4.4.6/include/omp.h
/usr/lib/gcc/x86_64-amazon-linux/4.8.5/include/omp.h
/usr/lib/gcc/x86_64-amazon-linux/6.4.1/include/omp.h

我安装了Developer Tools,并使用这些命令更新了Makeconf文件。

sudo sed -i 's/CC = gcc -m64/CC = gcc64 -m64/g' /usr/lib64/R/etc/Makeconf
sudo yum groupinstall 'Development Tools'

然后,我将这些行添加到Makevars配置文件中。

mkdir ~/.R
vi ~/.R/Makevars

CC=gcc
VER=64
CC=gcc$(VER)
CXX=g++$(VER)
CXX11=g++$(VER)
CXX14=g++$(VER)

我重新启动了RStudio服务器,并尝试安装ModelMetrics并收到此错误,与以前相同。

Installing package into ‘/home/User/R/x86_64-pc-linux-gnu-library/3.5’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/ModelMetrics_1.2.2.tar.gz'
Content type 'application/x-gzip' length 16974 bytes (16 KB)
==================================================
downloaded 16 KB

* installing *source* package ‘ModelMetrics’ ...
** package ‘ModelMetrics’ successfully unpacked and MD5 sums checked
** libs
g++  -I"/opt/R/3.5.3/lib64/R/include" -DNDEBUG  -I"/home/User/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -I/usr/local/include   -fpic  -g -O2  -c RcppExports.cpp -o RcppExports.o
g++  -I"/opt/R/3.5.3/lib64/R/include" -DNDEBUG  -I"/home/User/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -I/usr/local/include   -fpic  -g -O2  -c auc_.cpp -o auc_.o
auc_.cpp:2:10: fatal error: omp.h: No such file or directory
 #include <omp.h>
          ^~~~~~~
compilation terminated.
make: *** [auc_.o] Error 1
ERROR: compilation failed for package ‘ModelMetrics’
* removing ‘/home/User/R/x86_64-pc-linux-gnu-library/3.5/ModelMetrics’
Warning in install.packages :
  installation of package ‘ModelMetrics’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/RtmpTSUlz4/downloaded_packages’

2 个答案:

答案 0 :(得分:0)

您已将R配置为在编译C文件时使用gcc64,但是C ++文件仍将使用g++而不是g++64进行编译。 ~/.R/Makevars中的以下配置将对此进行一致更改:

VER=64
CC=gcc$(VER)
CXX=g++$(VER)
CXX11=g++$(VER)
CXX14=g++$(VER)

由于上述操作不适用于您,因此您可能会受到与此用户相同的问题的影响:https://stackoverflow.com/a/49876044/8416610在这种情况下,您可以使用以下方式编辑R的Makeconf文件

sudo sed -i 's/g++/g++64/' $(R RHOME)/etc/Makeconf

(假设您已将gcc更改为gcc64

答案 1 :(得分:0)

事实证明,Linux机器上的gcc版本有问题。

按照说明here,我能够用这两行代码解决问题。

sudo yum remove gcc72-c++.x86_64 libgcc72.x86_64
sudo yum groupinstall 'Development Tools'