Alexia
Alexia

Reputation: 21

error when installing R package pcalg on Rstudio: "clang: error: linker command failed with exit code 1"

I'm trying to install R package pcalg on Rstudio but I get the error message above. My operating system is MacOS Mojave 10.14.6 and I am using version 1.2.1335 of Rstudio.

I've tried installing it both with command

install.packages("pcalg")

and offline

install.packages("~/Downloads/pcalg_2.6-2.tar.gz", repos = NULL, type = "source")

but none of these options have worked. It seems that the problem occurs when it tries to compile the pcalg package which is only available in source form and needs compilation of either C/C++/Fortran.

Below is the error message:

gies.cpp:383:13: warning: enumeration value 'SD_NONE' not handled in switch [-Wswitch]
                                        switch(dir) {
                                               ^
gies.cpp:383:13: note: add missing switch cases
                                        switch(dir) {
                                               ^
1 warning generated.
clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppArmadillo/include" -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/BH/include" -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -I"../inst/include" -fPIC  -Wall -g -O2  -c greedy.cpp -o greedy.o
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppArmadillo/include" -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/BH/include" -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include  -fPIC  -Wall -g -O2  -c init.c -o init.o
clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppArmadillo/include" -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/BH/include" -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -I"../inst/include" -fPIC  -Wall -g -O2  -c score.cpp -o score.o
clang++ -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/usr/local/lib -o pcalg.so constraint.o gies.o greedy.o init.o score.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: directory not found for option '-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0'
ld: warning: directory not found for option '-L/usr/local/gfortran/lib'
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [pcalg.so] Error 1
ERROR: compilation failed for package ‘pcalg’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/pcalg’
Warning in install.packages :
  installation of package ‘pcalg’ had non-zero exit status

Upvotes: 2

Views: 1965

Answers (1)

Chelmy88
Chelmy88

Reputation: 1116

Apparently you miss the gfortran libraries. To see how to install the correct version, see : https://thecoatlessprofessor.com/programming/rcpp-rcpparmadillo-and-os-x-mavericks--lgfortran-and--lquadmath-error/

Upvotes: 2

Related Questions