Question: Issue setting up BiocManager due to mgcv / clang?
0
gravatar for benoahb
5 months ago by
benoahb0
benoahb0 wrote:

Hi all,

I'm new to R and it looks like I'm having issues setting up BiocManager and linked to the mgcv package and clang? See below. I'm running on macosx Mojave, I installed R, Rstudio, Xcode and Xcode command lines.

Any ideas?

Thanks, Ben

    > BiocManager::install()
Bioconductor version 3.8 (BiocManager 1.30.4), R 3.5.3 (2019-03-11)
Update old packages: 'mgcv'
Update all/some/none? [a/s/n]: 
a

  There is a binary version available but the source version is later:
     binary source needs_compilation
mgcv 1.8-27 1.8-28              TRUE

Do you want to install from sources the package which needs compilation? (Yes/no/cancel) Yes
installing the source package ‘mgcv’

trying URL 'https://cran.rstudio.com/src/contrib/mgcv_1.8-28.tar.gz'
Content type 'application/x-gzip' length 915991 bytes (894 KB)
==================================================
downloaded 894 KB

* installing *source* package ‘mgcv’ ...
** package ‘mgcv’ successfully unpacked and MD5 sums checked
** libs
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -fopenmp -fPIC  -Wall -g -O2  -c coxph.c -o coxph.o
clang: error: unsupported option '-fopenmp'
make: *** [coxph.o] Error 1
ERROR: compilation failed for package ‘mgcv’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/mgcv’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/mgcv’

The downloaded source packages are in
    ‘/private/var/folders/k7/4zfz3tnj6sv7c5vx6khz09kr0000gn/T/RtmpP8RQpe/downloaded_packages’
Warning message:
In install.packages(update[instlib == l, "Package"], l, repos = repos,  :
  installation of package ‘mgcv’ had non-zero exit status
software error • 259 views
ADD COMMENTlink modified 5 months ago by Martin Morgan ♦♦ 23k • written 5 months ago by benoahb0
Answer: Issue setting up BiocManager due to mgcv / clang?
1
gravatar for Martin Morgan
5 months ago by
Martin Morgan ♦♦ 23k
United States
Martin Morgan ♦♦ 23k wrote:

You've opted to install a source package on MacOS, so you need to install macOS developer tools; the alternative is to install the currently out-of-date binary by answering 'no', or to wait until an up-to-date binary has been produced.

ADD COMMENTlink written 5 months ago by Martin Morgan ♦♦ 23k

Well, as I said, I already installed Xcode, and it is up to date. I checked and gfortran is also up to date. The only thing missing was clang. It seemed outdated on your link but updated it with Homebrew and the LLVM package. I also took the last Command Line Tools macOS 10.14 for Xcode 10.2.

But I end up with the exact same error message in R

> BiocManager::install()
Bioconductor version 3.8 (BiocManager 1.30.4), R 3.5.3 (2019-03-11)
Update old packages: 'mgcv'
Update all/some/none? [a/s/n]: 
a

  There is a binary version available but the source version is later:
     binary source needs_compilation
mgcv 1.8-27 1.8-28              TRUE

Do you want to install from sources the package which needs compilation? (Yes/no/cancel) Yes
installing the source package ‘mgcv’

trying URL 'https://cran.rstudio.com/src/contrib/mgcv_1.8-28.tar.gz'
Content type 'application/x-gzip' length 915991 bytes (894 KB)
==================================================
downloaded 894 KB

* installing *source* package ‘mgcv’ ...
** package ‘mgcv’ successfully unpacked and MD5 sums checked
** libs
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -fopenmp -fPIC  -Wall -g -O2  -c coxph.c -o coxph.o
clang: error: unsupported option '-fopenmp'
make: *** [coxph.o] Error 1
ERROR: compilation failed for package ‘mgcv’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/mgcv’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/mgcv’

The downloaded source packages are in
    ‘/private/var/folders/k7/4zfz3tnj6sv7c5vx6khz09kr0000gn/T/RtmpvyYGoQ/downloaded_packages’
Warning message:
In install.packages(update[instlib == l, "Package"], l, repos = repos,  :
  installation of package ‘mgcv’ had non-zero exit status
ADD REPLYlink written 5 months ago by benoahb0
1

Sorry not to read your question closely enough. I think this is an R installation issue rather than Bioconductor (probably install.packages("mgcv") fails in the same way...?) but to troubleshoot, I'd guess that the -fopenmp flag is present in the file at R.home("etc/Makeconf"). Can you verify that, and if so show the line(s) where it occurs?

Actually, perhaps short-circuiting this trouble-shooting, see perhaps https://stackoverflow.com/a/43943631/547331

ADD REPLYlink modified 5 months ago • written 5 months ago by Martin Morgan ♦♦ 23k

Yeah, I tried install.packages("mgcv") with the same results.

Ok this is when I start to get lost. How do I verify "that the -fopenmp flag is present in the file at R.home("etc/Makeconf")"?

Also, I looked at the topic you linked. I already got clang but ran brew install gcc

I looked into /usr/local/opt/llvm/bin/clang and the files are there and gcc is at /usr/local/opt/gcc. "then you will have to add the compiler path to your ~/.R/Makevars file." I'm not sure what that means?

.. still the same missing -fopenmp results.

ADD REPLYlink modified 5 months ago • written 5 months ago by benoahb0
1

Type R.home("etc/Makeconf") into the R console, you'll get a path to a plain text file that you can open with any editor, e.g., RStudio. Look for lines containing -fopenmp.

The simplest solution is to simply say 'no' when asked to install the source version of mgcv.

The next simplest solution is likely to create a plain text file called 'Makevars' at the location returned by the R command normalizePath("~/.R/Makevars"). Use an editor (like RStudio) to insert two lines

SHLIB_OPENMP_CFLAGS=
SHLIB_OPENMP_CXXFLAGS=

I'm not really sure how you installed your R, but that's likely important if neither of the above two solutions are good enough.

ADD REPLYlink written 5 months ago by Martin Morgan ♦♦ 23k

I installed R using the macOS package from CRAN website.

Here are the lines containing -fopenmp

DYLIB_LDFLAGS = -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -fopenmp# $(CFLAGS) $(CPICFLAGS)
MAIN_LDFLAGS = -fopenmp
SHLIB_OPENMP_CFLAGS = -fopenmp
SHLIB_OPENMP_CXXFLAGS = -fopenmp
SHLIB_OPENMP_FCFLAGS = -fopenmp
SHLIB_OPENMP_FFLAGS = -fopenmp

And here's what I get

> normalizePath("~/.R/Makevars")
[1] "~/.R/Makevars"
Warning message:
In normalizePath("~/.R/Makevars") :
  path[1]="~/.R/Makevars": No such file or directory

There is no ~/.R directory for that matter...

ADD REPLYlink written 5 months ago by benoahb0
1

create the .R directory in your home directory (normalizePath("~/.") and a plain text file Makevars. Edit the Makevars file as indicated above.

I would guess that your version of clang is different from the one used by CRAN, and that you should use the version described on the page that I indicated above, but that would be an alternative solution and I would suggest trying to get the edited Makevars approach to work first.

ADD REPLYlink modified 5 months ago • written 5 months ago by Martin Morgan ♦♦ 23k

I created .R in my home directory normalizePath("~/.R") and made a plain text Makevars file as you suggested, however I still get this error message

Warning message:
In normalizePath("~/.R/Makevars") :
  path[1]="~/.R/Makevars": No such file or directory

I took the version of clang from CRAN but it doesn't work. It does say that it is the last version is for El Capitan. Is it that the commands have not been updated to Mojave and I'm screwed until it is?

ADD REPLYlink written 5 months ago by benoahb0
1

Did you create Makevars in the ~/.R directory?

ADD REPLYlink written 5 months ago by Martin Morgan ♦♦ 23k

I did, a plain text document...

ADD REPLYlink written 5 months ago by benoahb0
1

Troubleshoot why normalizePath("~/.R/Makevars") fails -- it says that the path doesn't exist, but you say that it does.

ADD REPLYlink written 5 months ago by Martin Morgan ♦♦ 23k

In the terminal, I can access ~/.R and the ls command gives me a Makevars.txt file.

Said file contains

SHLIB_OPENMP_CFLAGS=
SHLIB_OPENMP_CXXFLAGS=

Yet, in R, I still get this error message

> normalizePath("~/.R/Makevars")
[1] "~/.R/Makevars"
Warning message:
In normalizePath("~/.R/Makevars") :
  path[1]="/.R/Makevars": No such file or directory
ADD REPLYlink modified 5 months ago • written 5 months ago by benoahb0
1

The file needs to be Makevars, without the .txt extension.

ADD REPLYlink written 5 months ago by Martin Morgan ♦♦ 23k

Finally, it worked!! Thanks for the help!

ADD REPLYlink written 5 months ago by benoahb0
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 232 users visited in the last hour