gpt4 book ai didi

c++ - fatal error : auc_.cpp:2:10: fatal error: omp.h: No such file or directory

转载 作者:行者123 更新时间:2023-12-02 10:57:50 35 4
gpt4 key购买 nike

我正在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’

最佳答案

您已将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)

关于c++ - fatal error : auc_.cpp:2:10: fatal error: omp.h: No such file or directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55619370/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com