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

Cannot install package on Mac #12

Open
Anjan-stat opened this issue Aug 3, 2023 · 3 comments
Open

Cannot install package on Mac #12

Anjan-stat opened this issue Aug 3, 2023 · 3 comments

Comments

@Anjan-stat
Copy link

I'm trying to install SPARK on Mac but getting the following error
R version: 4.3.1
MacOC: M1 Pro

if(!require("SPARK", quietly = TRUE)){

  • devtools::install_github('xzhoulab/SPARK')
  • }
    Downloading GitHub repo xzhoulab/SPARK@HEAD
    ── R CMD build ─────────────────────────────────────────────────────────────────────────────
    ✔ checking for file ‘/private/var/folders/vy/r4cjr09n25j20vl1tfz6_glc0000gq/T/RtmpVBFa4H/remotesd7bb8837a4e/xzhoulab-SPARK-a8b4bf2/DESCRIPTION’ ...
    ─ preparing ‘SPARK’:
    ✔ checking DESCRIPTION meta-information ...
    ─ cleaning src
    ─ installing the package to process help pages
    -----------------------------------
    ─ installing source package ‘SPARK’ ...
    ** using staged installation
    ** libs
    using C++ compiler: ‘Apple clang version 14.0.3 (clang-1403.0.22.14.1)’
    using C++11
    using SDK: ‘MacOSX13.3.sdk’
    clang++ -arch arm64 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I'/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/Rcpp/include' -I'/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/RcppArmadillo/include' -I/opt/R/arm64/include -DARMA_64BIT_WORD=1 -fPIC -falign-functions=64 -Wall -g -O2 -Wall -pedantic -fdiagnostics-color=always -c RcppExports.cpp -o RcppExports.o
    clang++ -arch arm64 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I'/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/Rcpp/include' -I'/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/RcppArmadillo/include' -I/opt/R/arm64/include -DARMA_64BIT_WORD=1 -fPIC -falign-functions=64 -Wall -g -O2 -Wall -pedantic -fdiagnostics-color=always -c rcpparma_hello_world.cpp -o rcpparma_hello_world.o
    clang++ -arch arm64 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I'/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/Rcpp/include' -I'/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/RcppArmadillo/include' -I/opt/R/arm64/include -DARMA_64BIT_WORD=1 -fPIC -falign-functions=64 -Wall -g -O2 -Wall -pedantic -fdiagnostics-color=always -c spark_float.cpp -o spark_float.o
    clang++ -arch arm64 -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/arm64/lib -o SPARK.so RcppExports.o rcpparma_hello_world.o spark_float.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/opt/gfortran/lib/gcc/aarch64-apple-darwin20.0/12.2.0 -L/opt/gfortran/lib -lgfortran -lemutls_w -lquadmath -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
    ld: warning: directory not found for option '-L/opt/gfortran/lib/gcc/aarch64-apple-darwin20.0/12.2.0'
    ld: warning: directory not found for option '-L/opt/gfortran/lib'
    ld: library not found for -lgfortran
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make: *** [SPARK.so] Error 1
    ERROR: compilation failed for package ‘SPARK’
    ─ removing ‘/private/var/folders/vy/r4cjr09n25j20vl1tfz6_glc0000gq/T/RtmpLNv8Gq/Rinstd83d752bd7fe/SPARK’
    -----------------------------------
    ERROR: package installation failed
    Error: Failed to install 'SPARK' from GitHub:
    ! System command 'R' failed
@Streisenberg
Copy link

I have reinstalled gfortran, deleted and reinstalled xcode-build tool, edited and rebuilt the Makevars file (I may have made a mistake here). But I still get the same error. I would be very happy if someone could help. Thank you!

My machine info:
Platform : aarch64-apple-darwin20
R.version : 4.2.2
MacOS : Monterey (12.6.5)
Chip : Apple M1 Max

@ANWANGJHU
Copy link

ANWANGJHU commented May 13, 2024

Here is my solution:

  1. brew install gcc
  2. in terminal, type which gfortran. In my case, it returns /opt/homebrew/bin/gfortran

In terminal, type

mkdir -p ~/.R  
nano ~/.R/Makevars
  1. In the ~/.R/Makevars, add
FC = /opt/homebrew/bin/gfortran
F77 = /opt/homebrew/bin/gfortran
FLIBS = -L/opt/homebrew/lib/gcc/14 -lgfortran -lquadmath -lm

Note: /opt/homebrew/lib/gcc is the location of the gcc installed by homebrew, do ls /opt/homebrew/lib/gcc in terminal to find which number is available, in my case it is 14

@laleoarrow
Copy link

Here is my solution:

  1. brew install gcc
  2. in terminal, type which gfortran. In my case, it returns /opt/homebrew/bin/gfortran
  3. in terminal, type

In terminal, type

mkdir -p ~/.R  
nano ~/.R/Makevars
  1. In the ~/.R/Makevars, add
FC = /opt/homebrew/bin/gfortran
F77 = /opt/homebrew/bin/gfortran
FLIBS = -L/opt/homebrew/lib/gcc/14 -lgfortran -lquadmath -lm

Note: /opt/homebrew/lib/gcc is the location of the gcc installed by homebrew, do ls /opt/homebrew/lib/gcc in terminal to find which number is available, in my case it is 14

This approach can be applied to various R packages that require compilation for M-chip MacBooks. Thank you for providing such a valuable solution!

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

4 participants