gfortran not found; clang:error: linker command fialed wite exit code 1

57 Views Asked by At

I recently install and uninstalled my R and Rstuido. Now, I am getting trouble to source cpp file. My main question is how to solve the error and how to change te compiler to gcc instead of clang.

My errors are given:

using C++ compiler: ‘Apple clang version 15.0.0 (clang-1500.3.9.4)’
using SDK: ‘’
clang++ -arch x86_64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/include   -I"/Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/RcppArmadillo/include" -I"/Users/yuzi_mi/Desktop/~/RA-J-L/BSFP-1/C++" -I/opt/R/x86_64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -c likelihood.cpp -o likelihood.o
clang++ -arch x86_64 -std=gnu++17 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/x86_64/lib -o sourceCpp_9.so likelihood.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/usr/local/Cellar/gcc/13.2.0/bin/../libexec/gcc/x86_64-apple-darwin23/13 -L/usr/local/Cellar/gcc/13.2.0/bin/../libexec -lgfortran -lquadmath -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: library 'gfortran' not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [sourceCpp_9.so] Error 1

The Session informations are also given:

R version 4.3.3 Patched (2024-02-29 r86148)
Platform: x86_64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.0

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

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

time zone: America/Chicago
tzcode source: internal

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

loaded via a namespace (and not attached):
[1] compiler_4.3.3           tools_4.3.3              RcppArmadillo_0.12.8.1.0
[4] Rcpp_1.0.12   

Here is something I tried

which gfortran
/opt/homebrew/bin/gfortran
gfortran -v

Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/opt/homebrew/Cellar/gcc/13.2.0/bin/../libexec/gcc/aarch64-apple-darwin23/13/lto-wrapper
Target: aarch64-apple-darwin23
Configured with: ../configure --prefix=/opt/homebrew/opt/gcc --libdir=/opt/homebrew/opt/gcc/lib/gcc/current --disable-nls --enable-checking=release --with-gcc-major-version-only --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-13 --with-gmp=/opt/homebrew/opt/gmp --with-mpfr=/opt/homebrew/opt/mpfr --with-mpc=/opt/homebrew/opt/libmpc --with-isl=/opt/homebrew/opt/isl --with-zstd=/opt/homebrew/opt/zstd --with-pkgversion='Homebrew GCC 13.2.0' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --with-system-zlib --build=aarch64-apple-darwin23 --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.2.0 (Homebrew GCC 13.2.0) 

So I updated makeconf to be:

FC = /opt/local/bin/gfortran -arch x86_64
FCFLAGS = -Wall -g -O2 $(LTO_FC)
FCLIBS_XTRA = 
FFLAGS = -Wall -g -O2 $(LTO_FC)
FLIBS = -L/usr/local/Cellar/gcc/13.2.0/bin/../libexec/gcc/x86_64-apple-darwin23/13 -L/usr/local/Cellar/gcc/13.2.0/bin/../libexec -lgfortran -lquadmath
FPICFLAGS = -fPIC
FPIEFLAGS = -fPIE
F_VISIBILITY = 

But I still get the error that gfortran not found. Please help! Thank you!

0

There are 0 best solutions below