while install.packages("lmtest") on a fully-updated macos M1 system with brew
clang -I"/opt/homebrew/Cellar/r/4.2.2_1/lib/R/include" -DNDEBUG -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/xz/include -I/opt/homebrew/include -fPIC -Wno-implicit-function-declaration -c init.c -o init.o
/opt/homebrew/opt/gcc/bin/gfortran -fno-optimize-sibling-calls -fPIC -g -O2 -c pan.f -o pan.o
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/opt/homebrew/Cellar/r/4.2.2_1/lib/R/lib -L/opt/homebrew/opt/gettext/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/xz/lib -L/opt/homebrew/lib -o lmtest.so init.o pan.o -L/opt/homebrew/opt/gcc/lib/gcc/current/gcc/aarch64-apple-darwin22/12 -L/opt/homebrew/opt/gcc/lib/gcc/current/gcc -L/opt/homebrew/opt/gcc/lib/gcc/current -lgfortran -lemutls_w -lquadmath -L/opt/homebrew/Cellar/r/4.2.2_1/lib/R/lib -lR -lintl -Wl,-framework -Wl,CoreFoundation
ld: warning: directory not found for option '-L/opt/homebrew/opt/gcc/lib/gcc/current/gcc/aarch64-apple-darwin22/12'
ld: library not found for -lemutls_w
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [lmtest.so] Error 1
one way to fix the problem is
> sudo bash
# cd /opt/homebrew/opt/gcc/lib/gcc/current/gcc
# ln -s aarch64-apple-darwin21 aarch64-apple-darwin22
it's a hack, of course. not sure why the author and I have a mismatch here, but this makes it work again.
Related
I managed to use the same laptop Mac pro 14 to run Rcpp a couple months ago. Due to some reason I have to erase everything from the Laptop and reinstall. But after following the instruction in this websitewhich worked for me last time, I still got the following error when sourcing a Cpp file in Rstudio.
The previous question I askedhere
ld: warning: directory not found for option '-L/opt/R/arm64/gfortran/lib/gcc/aarch64-apple-darwin20.6.0/12.0.1'
ld: warning: directory not found for option '-L/opt/R/arm64/gfortran/lib'
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [sourceCpp_2.so] Error 1
clang++ -arch arm64 -std=gnu++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/include -I"/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/RcppArmadillo/include" -I"/Users/yanghongguo/Desktop" -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c helloworld.cpp -o helloworld.o
clang++ -arch arm64 -std=gnu++14 -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 sourceCpp_2.so helloworld.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/opt/R/arm64/gfortran/lib/gcc/aarch64-apple-darwin20.6.0/12.0.1 -L/opt/R/arm64/gfortran/lib -lgfortran -lemutls_w -lquadmath -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
Error in sourceCpp("~/Desktop/helloworld.cpp") :
Error 1 occurred building shared library.
I tried to manually link to /opt/R/arm64/bin by
sudo ln -s /usr/local//gfortran/bin/gfortran /opt/R/arm64/bin
doesn't work.
I redo every step several times and installed different versions of Xcode but nothing work this time, so upset! Please help me with this issue.
I need to recompile some old functions to work r again (I had no problem with them back in 2016). Here are the commands and the error msg:
system("R CMD SHLIB rk4_mod_r.f90 derive_rossler.f90 simulate_rk4.f90 -o simulate_rossler_rk4.so");
gfortran -arch x86_64 -fPIC -g -O2 -c rk4_mod_r.f90 -o rk4_mod_r.o
gfortran -arch x86_64 -fPIC -g -O2 -c derive_rossler.f90 -o derive_rossler.o
gfortran -arch x86_64 -fPIC -g -O2 -c simulate_rk4.f90 -o simulate_rk4.o
gfortran -arch x86_64 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/clang4/lib -o simulate_rossler_rk4.so rk4_mod_r.o derive_rossler.o simulate_rk4.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: framework not found CoreFoundation
collect2: error: ld returned 1 exit status
make: *** [simulate_rossler_rk4.so] Error 1
~.R/Makevars is as follows
VER=-8
CC=gcc$(VER)
CXX=g++$(VER)
CXX11=g++$(VER)
CXX14=g++$(VER)
CXX17=g++$(VER)
CFLAGS=-mtune=native -g -O2 -Wall -pedantic -Wconversion
CXXFLAGS=-mtune=native -g -O2 -Wall -pedantic -Wconversion
FLIBS=-L/usr/local/Cellar/gcc/8.3.0/lib/gcc/8
I noticed that -L/usr/local/clang4/lib is there. I am not sure if that is correct. I tried the same command by replacing it to -L/usr/local/Cellar/gcc/8.3.0/lib/gcc/8 to no avail.
What am I missing?
Many thanks,
Ed
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
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/
I'm trying to install BASiCS in R 3.4.2 on macOS High Sierra. I've installed R via homebrew. I've also installed gfortran as part of gcc via brew install gcc.
Still, I get the error below. Does anyone have a clue how to resolve this?
Thanks,
ERROR MESSAGE IN R
Downloading GitHub repo catavallejos/BASiCS#master
from URL https://api.github.com/repos/catavallejos/BASiCS/zipball/master
Installing BASiCS
'/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file --no-environ \
--no-save --no-restore --quiet CMD INSTALL \
'/private/var/folders/xk/dfj20kgd56xg8796xh874tjr0000gn/T/RtmpW243tu/devtools3375bbc3c81/catavallejos-BASiCS-407caff' \
--library='/Library/Frameworks/R.framework/Versions/3.4/Resources/library' \
--install-tests
* installing *source* package ‘BASiCS’ ...
** libs
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/RcppArmadillo/include" -I/usr/local/include -fPIC -Wall -g -O2 -c BASiCS_CPPcode.cpp -o BASiCS_CPPcode.o
In file included from BASiCS_CPPcode.cpp:12:
In file included from /Library/Frameworks/R.framework/Versions/3.4/Resources/library/RcppArmadillo/include/RcppArmadillo.h:31:
In file included from /Library/Frameworks/R.framework/Versions/3.4/Resources/library/RcppArmadillo/include/RcppArmadilloForward.h:26:
In file included from /Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include/RcppCommon.h:122:
/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include/Rcpp/exceptions.h:103:53: warning: all paths through this function will call itself
[-Winfinite-recursion]
inline void warning(const std::string& message) { // #nocov start
^
1 warning generated.
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/RcppArmadillo/include" -I/usr/local/include -fPIC -Wall -g -O2 -c RcppExports.cpp -o RcppExports.o
clang++ -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 BASiCS.so BASiCS_CPPcode.o RcppExports.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: *** [BASiCS.so] Error 1
ERROR: compilation failed for package ‘BASiCS’
* removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/BASiCS’
Installation failed: Command failed (1)
It seems you need to install gfortran from CRAN, rather than via homebrew.
I had the same problem and solved it with this github recommendation.
I am able to use my existing versions of R and RStudio just fine, but I cannot seem to sync the version I have in /Applications with the Terminal in El Capitan, which means I cannot use ESS in emacs.
shermmac:~ brandonsherman$ brew install R
==> Installing r from homebrew/homebrew-science
==> Using Homebrew-provided fortran compiler.
This may be changed by setting the FC environment variable.
==> Downloading http://cran.rstudio.com/src/base/R-3/R-3.2.2.tar.gz
Already downloaded: /Library/Caches/Homebrew/r-3.2.2.tar.gz
==> Patching
patching file src/modules/lapack/vecLibg95c.c
==> ./configure --prefix=/usr/local/Cellar/r/3.2.2_1 --with-libintl-
==> make
Last 15 lines from /Users/brandonsherman/Library/Logs/Homebrew/r/02.make:
5: In as.POSIXlt.POSIXct(x, tz) : unknown timezone 'America/New_York'
clang -I../../../../include -DNDEBUG -I/usr/local/include -I/usr/local/include -I/usr/X11/include -I../../../include -I../../../../src/include -DHAVE_CONFIG_H -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include -fPIC -g -O2 -c init.c -o init.o
clang -I../../../../include -DNDEBUG -I/usr/local/include -I/usr/local/include -I/usr/X11/include -I../../../include -I../../../../src/include -DHAVE_CONFIG_H -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include -fPIC -g -O2 -c tcltk.c -o tcltk.o
clang -I../../../../include -DNDEBUG -I/usr/local/include -I/usr/local/include -I/usr/X11/include -I../../../include -I../../../../src/include -DHAVE_CONFIG_H -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include -fPIC -g -O2 -c tcltk_unix.c -o tcltk_unix.o
making tcltk.d from tcltk.c
making init.d from init.c
making tcltk_unix.d from tcltk_unix.c
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L../../../../lib -L/usr/local/opt/gettext/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/openssl/lib -o tcltk.so init.o tcltk.o tcltk_unix.o -L/usr/local/lib -ltcl8.6 -L/usr/local/lib -ltk8.6 -L/usr/X11/lib -lX11 -Wl,-weak-lXss -lXext -L../../../../lib -lR -lintl -Wl,-framework -Wl,CoreFoundation
ld: library not found for -lX11
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[4]: *** [tcltk.so] Error 1
make[3]: *** [all] Error 1
make[2]: *** [R] Error 1
make[1]: *** [R] Error 1
make: *** [R] Error 1
READ THIS: https://git.io/brew-troubleshooting
If reporting this issue please do so at (not Homebrew/homebrew):
https://github.com/homebrew/homebrew-science/issues
Warning:
Note that there is nothing after Warning:.
I reinstalled Command Line Tools for 10.10 and rebooted. I then installed R 3.2.2 via Homebrew as in the original question. It gave me the following error regarding my gfortran compiler:
dyld: Library not loaded: /usr/local/lib/gcc/5/libgfortran.3.dylib
Referenced from: /usr/local/Cellar/r/3.2.2_1/R.framework/Versions/3.2/Resources/lib/libR.dylib
Reason: image not found
dyld: Library not loaded: /usr/local/lib/gcc/5/libgfortran.3.dylib
Referenced from: /usr/local/Cellar/r/3.2.2_1/R.framework/Versions/3.2/Resources/lib/libR.dylib
Reason: image not found
brew link gcc got rid of this error. R now works fine.