Using OSX? Compiling an R package from source? Issues with ‘-fopenmp’? Try this.

November 18, 2018
By

(This article was first published on R – What You're Doing Is Rather Desperate, and kindly contributed to R-bloggers)

You can file this one under “I may have the very specific solution if you’re having exactly the same problem.”

So: if you’re running some R code and you see a warning like this:

Warning message:
In checkMatrixPackageVersion() : Package version inconsistency detected.
TMB was built with Matrix version 1.2.14
Current Matrix version is 1.2.15
Please re-install 'TMB' from source using 
install.packages('TMB', type = 'source') or ask CRAN for a binary 
version of 'TMB' matching CRAN's 'Matrix' package

And installation of TMB from source fails like this:

install.packages("TMB", type = "source")
clang: error: unsupported option '-fopenmp'
make: *** [external_metis.o] Error 1
ERROR: compilation failed for package ‘TMB’

And you use Homebrew – first, do this:

brew install llvm

Then create the file ~/.R/Makevars, if it does not exist and edit its contents to look like this:

C=/usr/local/opt/llvm/bin/clang
CXX=/usr/local/opt/llvm/bin/clang++

Your R package should now compile without error. If it works as it did for me 🙂

To leave a comment for the author, please follow the link and comment on their blog: R – What You're Doing Is Rather Desperate.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Sponsors

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)