xuyiqing / gsynth

Generalized Synthetic Control Method
Other
132 stars 40 forks source link

fail to install on macOS sierra #3

Closed yimingli closed 6 years ago

yimingli commented 6 years ago

I couldn't install the package on my mac. Some googling around suggests the problem might be that Apple's clang does not support openMP. But I'm not sure how to fix it. Thanks.

Here is the error message:

> install.packages('gsynth', type = 'source')
Installing package into ‘/Users/paul/Library/R/3.4/library’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/gsynth_1.0.6.tar.gz'
Content type 'application/x-gzip' length 100150 bytes (97 KB)
==================================================
downloaded 97 KB

* installing *source* package ‘gsynth’ ...
** package ‘gsynth’ successfully unpacked and MD5 sums checked
** libs
clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I"/Users/paul/Library/R/3.4/library/Rcpp/include" -I"/Users/paul/Library/R/3.4/library/RcppArmadillo/include" -I/usr/local/include  -fopenmp  -fPIC  -Wall -g -O2 -c RcppExports.cpp -o RcppExports.o
clang: error: unsupported option '-fopenmp'
make: *** [RcppExports.o] Error 1
ERROR: compilation failed for package ‘gsynth’
* removing ‘/Users/paul/Library/R/3.4/library/gsynth’
Warning in install.packages :
  installation of package ‘gsynth’ had non-zero exit status

Here is the session info:

> sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.6

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_3.4.1 tools_3.4.1    yaml_2.1.14 
xuyiqing commented 6 years ago

Hi, this is not a problem with gsynth, but a problem with Mac C++ compiler. Check out this page:

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

On Mon, Oct 16, 2017 at 3:39 PM, Yiming (Paul) Li notifications@github.com wrote:

I couldn't install the package on my mac. Some googling around suggests the problem might be that Apple's clang does not support openMP. But I'm not sure how to fix it. Thanks.

Here is the error message:

install.packages('gsynth', type = 'source') Installing package into ‘/Users/paul/Library/R/3.4/library’ (as ‘lib’ is unspecified) trying URL 'https://cran.rstudio.com/src/contrib/gsynth_1.0.6.tar.gz' Content type 'application/x-gzip' length 100150 bytes (97 KB)

downloaded 97 KB

  • installing source package ‘gsynth’ ... package ‘gsynth’ successfully unpacked and MD5 sums checked libs clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I"/Users/paul/Library/R/3.4/library/Rcpp/include" -I"/Users/paul/Library/R/3.4/library/RcppArmadillo/include" -I/usr/local/include -fopenmp -fPIC -Wall -g -O2 -c RcppExports.cpp -o RcppExports.o clang: error: unsupported option '-fopenmp' make: *** [RcppExports.o] Error 1 ERROR: compilation failed for package ‘gsynth’
  • removing ‘/Users/paul/Library/R/3.4/library/gsynth’ Warning in install.packages : installation of package ‘gsynth’ had non-zero exit status

Here is the session info:

sessionInfo() R version 3.4.1 (2017-06-30) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS Sierra 10.12.6

Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages: [1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached): [1] compiler_3.4.1 tools_3.4.1 yaml_2.1.14

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/xuyiqing/gsynth/issues/3, or mute the thread https://github.com/notifications/unsubscribe-auth/AHT1GAVzshNIviLRgl_K456KmTXgFNn5ks5ss9s3gaJpZM4P7Vyk .

-- Yiqing Xu

Assistant Professor Department of Political Science University of California, San Diego http://yiqingxu.org/

yimingli commented 6 years ago

It worked. Thanks a lot!

For the convenience of potential readers, here is what I installed on my system (R version 3.4.1, macOS Sierra 10.12.6) to fix the problem:

  1. gfortran 6.1 from https://gcc.gnu.org/wiki/GFortranBinaries#MacOS
  2. clang4 R Binaries from https://github.com/coatless/r-macos-clang
xuyiqing commented 6 years ago

Thank you. I'll put it in the ReadMe file!

On Mon, Oct 16, 2017 at 5:36 PM, Yiming (Paul) Li notifications@github.com wrote:

It worked. Thanks a lot!

For the convenience of potential readers, here is what I installed to fix the problem:

  1. gfortran 6.1 from https://gcc.gnu.org/wiki/GFortranBinaries#MacOS
  2. clang4 R Binaries from https://github.com/coatless/r-macos-clang

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/xuyiqing/gsynth/issues/3#issuecomment-337082968, or mute the thread https://github.com/notifications/unsubscribe-auth/AHT1GFNsDb5nuC9Off2h3E5i00nf-Mw9ks5ss_aTgaJpZM4P7Vyk .

-- Yiqing Xu

Assistant Professor Department of Political Science University of California, San Diego http://yiqingxu.org/

coatless commented 6 years ago

@xuyiqing update README.md to

https://github.com/coatless/r-macos-rtools

This setups the macOS toolchain, e.g. Xcode CLI, clang4, and gfortran. No terminal is required.