Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang: error: unsupported option '-fopenmp' #143

Closed
binxiangni opened this issue Jul 8, 2017 · 21 comments
Closed

clang: error: unsupported option '-fopenmp' #143

binxiangni opened this issue Jul 8, 2017 · 21 comments

Comments

@binxiangni
Copy link
Contributor

When I test codes in MacOS, the error message above showed up. I tried some methods on stackoverflow but they didn't work. Any idea?

@coatless
Copy link
Contributor

coatless commented Jul 8, 2017

Read: http://thecoatlessprofessor.com/programming/openmp-in-r-on-os-x/

@binxiangni
Copy link
Contributor Author

binxiangni commented Jul 8, 2017

The initial error disappeared after I followed the instructions from the post, but a new one comes out:

checking whether we are cross compiling... configure: error: in `/private/var/folders/xn/46r52scd6_v17k8qb28tpflh0000gn/T/RtmpPQupxB/Rbuild282a768a148a/RcppArmadillo':
configure: error: cannot run C++ compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details

@coatless
Copy link
Contributor

coatless commented Jul 8, 2017

  1. Installed Xcode CLI
  2. Installed clang4 (once) with the installer? (Check only one LDFLAGS is set in ~/.R/Makevars)
  3. Installed gfortran 6.1
  4. Restarted R?

@binxiangni
Copy link
Contributor Author

Now I reinstall Xcode, then the error is away. Thanks! 👍

@gurol
Copy link

gurol commented May 3, 2018

@eddelbuettel
Copy link
Member

@gurol ? We have made half a dozen releases since that report, rewrote the architecture detection and have just seen R Core give us new macOS tools. The comment may be a little out of sync, as well-intended as it may be.

@dpastoor
Copy link

dpastoor commented May 4, 2018

@eddelbuettel not completely out of of sync - from @vjd after fresh R OSX install + new macOS tools getting this exact error

image

@vjd
Copy link

vjd commented May 4, 2018

@dpastoor thanks.
@eddelbuettel My MakeVars looks like this.

CC=/usr/local/clang6/bin/clang
CXX=/usr/local/clang6/bin/clang++
LDFLAGS=-L/usr/local/clang6/lib

@eddelbuettel
Copy link
Member

@coatless Can you chime in? Which clang version should people use? What documentation should we point to? I was under the impression this was now ironed out?

@kylebaron
Copy link

No issues here:

F77 = /usr/local/bin/gfortran
FC = $F77
CXX = ccache /usr/local/clang6/bin/clang++  -Wall
LDFLAGS=-L/usr/local/clang6/lib
CC= ccache /usr/local/clang6/bin/clang
SHLIB_CXXLD=ccache /usr/local/clang6/bin/clang++
CXX11 = ccache /usr/local/clang6/bin/clang++
CXX98 = ccache /usr/local/clang6/bin/clang++
CXX14 = ccache /usr/local/clang6/bin/clang++

@coatless
Copy link
Contributor

coatless commented May 4, 2018

@eddelbuettel in short, I gotta spend time updating documentation for the R 3.5.* line as it uses clang6 instead of clang4...

@vjd
Copy link

vjd commented May 4, 2018

@kylebmetrum My makevars reflects what you have mostly, so I don't see an issue. I updated to reflect your config. Now, I get the following error below. Is this a permissions thing?

configure: error: in `/private/var/folders/c1/ydghd7v17g16f0_nw47gvqmm0000gn/T/RtmpVeAriM/R.INSTALLab22eb1a962/RcppArmadillo':
configure: error: C++ compiler cannot create executables
See `config.log' for more details
ERROR: configuration failed for package ‘RcppArmadillo’
* removing ‘/Users/vijay/Dropbox (Personal)/rlibs/RcppArmadillo’
Warning in install.packages :
  installation of package ‘RcppArmadillo’ had non-zero exit status

@coatless
Copy link
Contributor

coatless commented May 4, 2018

@vjd post the config.log and your ~/.R/Makevars

@coatless
Copy link
Contributor

coatless commented May 4, 2018

The issue we are running into here is the binary from R is configured for usage on CRAN. Local machines still need a lot of options set.

@vjd
Copy link

vjd commented May 4, 2018

@coatless I used the same ~/.R/Makevars as @kylebmetrum

where can I find the config.log?

@coatless
Copy link
Contributor

coatless commented May 4, 2018

Should be in /private/var/folders/c1/ydghd7v17g16f0_nw47gvqmm0000gn/T/RtmpVeAriM/R.INSTALLab22eb1a962/RcppArmadillo

@vjd
Copy link

vjd commented May 4, 2018

That's where I tired initially.. but is this temp folder blown away after failed install?

image

@eddelbuettel
Copy link
Member

Maybe do it the other way around: create a temp directory, change into it, copy the RcppArmadillo tarball, unpack it and run ./configure. The log file will be there. R does the same for you but cleans up temp dirs which you do not want now.

@vjd
Copy link

vjd commented May 4, 2018

@eddelbuettel Thanks. I went through the config file as you suggested and realized that ccache may have been an alias in @kylebmetrum Makevars . Once I removed that and reran the installation, it worked fine.

To summarise -
I was upgrading to R 3.5 on MacOS Sierra and subsequently was updating the Rcpparmadillo package. I used the macos tools from here - https://cran.r-project.org/bin/macosx/tools/ to download clang6 and gfortran.

My initial Makevars looked like this -

CC=/usr/local/clang6/bin/clang
CXX=/usr/local/clang6/bin/clang++
LDFLAGS=-L/usr/local/clang6/lib

This caused failed installation due to the -fopenmp issue posted above.

I then updated my Makevars file to match that posted by @kylebmetrum. I had to remove the ccache which is probably an alias and my final Makevars file looks like this now.

F77 = /usr/local/bin/gfortran
FC = $F77
CXX =  /usr/local/clang6/bin/clang++  -Wall
LDFLAGS=-L/usr/local/clang6/lib
CC=  /usr/local/clang6/bin/clang
SHLIB_CXXLD=ccache /usr/local/clang6/bin/clang++
CXX11 =  /usr/local/clang6/bin/clang++
CXX98 =  /usr/local/clang6/bin/clang++
CXX14 =  /usr/local/clang6/bin/clang++

The installation was complete with this.

Thanks @coatless and @eddelbuettel

@kylebaron
Copy link

@vjd ccache is a program to speed up installation by caching; highly recommended

See: http://dirk.eddelbuettel.com/blog/2017/11/27/

And: https://ccache.samba.org/

@eddelbuettel
Copy link
Member

eddelbuettel commented May 4, 2018

Yes -- ccache is highly recommended especially when you compile the same (C/C++/...) sources multiple times -- eg when building / testing an R packages. And it is orthogonal to the what R uses. g++ and clang++ just "don't know" that they are wrapped in ccache calls.

Also, as you just relearned the hard way, do not just copy a setup blindly. You clearly could copy ccache when you did not have it installed. Sorry for the bother, it leaks out of my examples too -- but there is a wee amount of 'buyer beware' here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants