0

I'm running RServer Studio on a Linux box on AWS.

I tried to install ModelMetrics, a dependency for caret, and received this error:

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’

This is the full output message

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’

I looked around SO and it looks like there is an error with the compiler. I tried the solutions listed here, specifically I ran these commands

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

Even after restarting RStudio Server, I get the same output and error message.

It looks like this error is very similar to the problem here. I still don't have a solution after following those instructions, but I did find the location of my omp.h file.

/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

I installed Developer Tools and updated the Makeconf file using these commands.

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

Then, I added these lines to the Makevars config file.

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

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

I restarted the RStudio Server and tried to install ModelMetrics and received this error, the same as before.

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’
5
  • what is your gcc --version?
    – coder3101
    Apr 10, 2019 at 19:42
  • I started a brand new linux machine and got gcc (GCC) 7.2.1 20170915 (Red Hat 7.2.1-2)
    – Cauder
    Apr 10, 2019 at 19:44
  • Note that none of the omp.h files you found are for gcc version 7.2.1. Apr 11, 2019 at 4:55
  • The new error log shows that g++ is still used instead of g++64. What is the output of R CMD config CXX? Apr 11, 2019 at 16:32
  • The output is g++64
    – Cauder
    Apr 11, 2019 at 16:36

2 Answers 2

1

You have configured R to use gcc64 when compiling C files, but C++ files will still be compiled with g++ instead of g++64. The following configuration in ~/.R/Makevars will change that consistently:

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

Since the above does not work for you, you might be affected by the same issues as this user: https://stackoverflow.com/a/49876044/8416610 In that case you can edit R's Makeconf file with

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

(assuming you alredy changed gcc to gcc64)

9
  • I'm not sure how to make a config file. Do I just copy and paste those commands?
    – Cauder
    Apr 11, 2019 at 15:48
  • I added that, and I also installed Development Tools and ran sudo sed -i 's/CC = gcc -m64/CC = gcc64 -m64/g' /usr/lib64/R/etc/Makeconf, but I get the same error
    – Cauder
    Apr 11, 2019 at 16:16
  • @Cauder Please post the full error output after this change. Apr 11, 2019 at 16:18
  • I'll do that. Thanks Ralf.
    – Cauder
    Apr 11, 2019 at 16:30
  • 1
    Got it! These two lines fixed it sudo yum remove gcc72-c++.x86_64 libgcc72.x86_64 sudo yum groupinstall 'Development Tools'
    – Cauder
    Apr 11, 2019 at 17:31
0

It turns out that there was something wrong with the version of gcc on the linux box.

Per the instructions here, I was able to fix the problem with these two lines of code.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.