I recently "upgraded" to XCode 5.2 and now a number of R packages will not work. I have a 15" MBP running OSX Mavericks 10.9.1 and am running R 3.0.2.
First, the mcmc function in the package diversitree broke and gave the following error:
Error in .External(list(name = "CppMethod__invoke_notvoid", address = <pointer: 0x0>, :
NULL value passed as symbol address
Furthermore, I cannot compile the package "geomorph" from source, and I get the following error:
clang: error: no such file or directory: 'SHLIB_LIBADD'
clang: error: no such file or directory: '='
make: *** [geomorph.so] Error 1
ERROR: compilation failed for package ‘geomorph’
So I believe the error is somewhere in the compilers. I tested this idea with:
> require(Rcpp)
> evalCpp("1+1")
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I"/Users/Chris/Library/R/3.0/library/Rcpp/include" -fPIC "-mtune=native -g -O2 -Wall -pedantic -Wconversion" -c file177c642d0b53.cpp -o file177c642d0b53.o clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -L/usr/local/lib -o sourceCpp_1783.so file177c642d0b53.o /Users/Chris/Library/R/3.0/library/Rcpp/lib/libRcpp.a SHLIB_LIBADD = -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
Error in sourceCpp(code = code, env = env, rebuild = rebuild, showOutput = showOutput, :
Error 1 occurred building shared library.
WARNING: The tools required to build C++ code for R were not found.
Please install Command Line Tools for XCode (or equivalent).
clang: error: no such file or directory: 'SHLIB_LIBADD'
clang: error: no such file or directory: '='
make: *** [sourceCpp_1783.so] Error 1
Also this:
has_devel()
'/Library/Frameworks/R.framework/Resources/bin/R' --vanilla \
CMD SHLIB foo.c
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -fPIC "-mtune=native -g -O2 -Wall -pedantic -Wconversion" -c foo.c -o foo.o
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -L/usr/local/lib -o foo.so foo.o SHLIB_LIBADD = -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
clang: error: no such file or directory: 'SHLIB_LIBADD'
Error: Command failed (1)
clang: error: no such file or directory: '='
make: *** [foo.so] Error 1
I tried reinstalling Rcpp from source and that fails too:
clang: error: no such file or directory: 'SHLIB_LIBADD'
clang: error: no such file or directory: '='
make: *** [Rcpp.so] Error 1
I've spent hours now trying to troubleshoot this and I've run across numerous mentions of editing the Makeconf file to add clang. I have done this but still cannot get things that use C in R to work. I would greatly appreciate any help.
Are you using a CRAN-provided binary of R, or your own compiled version of R? Did you compile R with your new XCode compilers or the old ones?
My experience is that CRAN-R will work fine with a specific compiler toolchain, as long as you use the same toolchain for all the packages you compile. If you, for example, try to link a new-XCode compiled package to an old-XCode compiled Rcpp, you will have problems.
Your SHLIB_LIBADD error, as far as I can guess, says you did something weird in your Makevars or Makeconf and now things are going wrong in parsing the files. I'd be curious to see if you can reproduce this with a fresh, CRAN-provided R.
Can you reproduce the problem if you try to re-install R + all your packages? You should try re-installing R with a fresh library directory, and then re-installing these problematic packages, and going from there.
Related
I'm using an M1 mac and attempting to install the package TESS3_encho_sen into R from github using the command devtools::install_github("bcm-uga/TESS3_encho_sen")
Upon doing so I receive the following error:
Error: Could not find tools necessary to compile a package
Call `pkgbuild::check_build_tools(debug = TRUE)` to diagnose the problem.
And calling pkgbuild::check_build_tools(debug = TRUE) is redundant and gives the same error as above. However, calling devtools::load_all() generates the following:
Error in `value[[3L]]()`:
! Could not find a root 'DESCRIPTION' file that starts with '^Package' in
~/path/to/file.
Are you in your project directory and does your project have a 'DESCRIPTION' file?
I found one potential workaround here HERE that suggested the errors were related to C/C++ library headers, but this solution did not work for me. Suppressing RStudio's build tools check as suggested HERE also did not work. Any help with this issue is appreciated!
Edit: I am now receiving the following error when running pkgbuild::check_build_tools(debug=TRUE):
Running /Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB foo.c
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c foo.c -o foo.o
warning: optimization flag '-falign-functions=64' is not supported [-Wignored-optimization-argument]
/usr/local/clang4/bin/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/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib -L/usr/local/clang4/lib -o foo.so foo.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: framework not found CoreFoundation
clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [foo.so] Error 1
This is likely an error installing PCRE2 (which I did using "sudo port install pcre2"), but when I "make" sample code for RInside, I get:
$ make rinside_sample0
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include -I/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RInside/include -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include rinside_sample0.cpp -L/usr/local/lib -F/Library/Frameworks/R.framework/.. -framework R -L/usr/local/lib -lpcre2-8 -llzma -lbz2 -lz -licucore -ldl -lm -liconv -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/Library/Frameworks/R.framework/Resources/lib -lRlapack /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RInside/lib/libRInside.a -o rinside_sample0
In file included from rinside_sample0.cpp:10:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RInside/include/RInside.h:26:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RInside/include/RInsideCommon.h:38:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/Rcpp.h:57:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/Rcpp/DataFrame.h:136:18: warning: unused variable 'data'
[-Wunused-variable]
SEXP data = Parent::get__();
^
1 warning generated.
ld: library not found for -lpcre2-8
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [rinside_sample0] Error 1
$
Thank you for the comment, Dirk. You got me pointed in the correct direction. I had two old versions of code: pcre2 and Rcpp.
I followed the directions for installing the latest version of "pcre2" here: https://izziswift.com/how-to-install-pcre-development-headers-on-mac-osx/.
I downloaded "pcre" version 10.39, cd'd to that directory, ran:
./configure
make
make install
After that, the examples in RInside compiled, but I got a runtime error:
$ ./rinside_sample0
Error: function 'Rcpp_precious_remove' not provided by package 'Rcpp'
Execution halted
$
Some searching showed that error arose from running an older version (1.0.6) of "Rcpp". I went into RStudio, typed "install.packages("Rcpp")" to update to version 1.0.7 and now everything runs!
Hopefully going through these steps will help anyone else who encounters these problems.
I've downloaded an old repo on a new laptop (running on MacOS Catalina) and attempted to run a R script.
The repo has a renv lock file - meaning, I should be able to restore all dependencies as they were.
But as I run the renv::restore() command, this error message appears:
Installing pbapply [1.4-3] ...
OK [linked cache]
Installing mvtnorm [1.1-2] ...
FAILED
Error installing package 'mvtnorm':
===================================
* installing to library ‘~/renv/staging/2’
* installing *source* package ‘mvtnorm’ ...
** package ‘mvtnorm’ successfully unpacked and MD5 sums checked
** libs
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c C_FORTRAN_interface.c -o C_FORTRAN_interface.o
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c miwa.c -o miwa.o
gfortran -fPIC -g -O2 -c mvt.f -o mvt.o
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c mvtnorm-init.c -o mvtnorm-init.o
gfortran -fPIC -g -O2 -c tvpack.f -o tvpack.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 mvtnorm.so C_FORTRAN_interface.o miwa.o mvt.o mvtnorm-init.o tvpack.o -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: *** [mvtnorm.so] Error 1
ERROR: compilation failed for package ‘mvtnorm’
* removing ‘~/renv/staging/2/mvtnorm’
------------------------------------------------------------------------------
R was unable to find one or more FORTRAN libraries during compilation.
This often implies that the FORTRAN compiler has not been properly configured.
Please see https://stackoverflow.com/q/35999874 for more information.
Reason(s):
- 'ld: library not found for -lgfortran'
Error: install of package 'mvtnorm' failed [error code 1]
Traceback (most recent calls last):
13: renv::restore()
12: renv_restore_run_actions(project, diff, current, lockfile, rebuild)
11: renv_install(records)
10: renv_install_staged(records)
9: renv_install_default(records)
8: handler(package, renv_install_impl(record))
7: renv_install_impl(record)
6: withCallingHandlers(renv_install_package_local(record), error = function(e) {
vwritef("\tFAILED")
writef(e$output)
})
5: renv_install_package_local(record)
4: renv_install_package_local_impl(package, path)
3: r_cmd_install(package, path)
2: r_exec_error(package, output, "install", status)
1: stop(error)
I can't make sense of the link in the error message (copied here: Mac OS X R error "ld: warning: directory not found for option").
From my problem search, I've come across some possible solutions that are above my R knowledge level, e.g.:
"[...] creating the file ~/.R/Makevars within my home directory." (Unable to install fortran based packages in R - "gfortran -m32:not found")
"[...] installed gcc & gcc-fortran and that solved it" (Unable to install a package on R)
Similar ideas here: OS X package installation depends on gfortran-4.8
Some guidance here would be deeply appreciated. Please let me know if there's any other info you need (first time posting here).
Thanks in advance!
Solution
Download and install "gfortran-6.1.pkg (OS X 10.11+, signed, 64-bit)" from this page: https://cran.r-project.org/bin/macosx/tools/
I’m running into issues while trying to install the rJava package on my Mac. I have tried the solutions proposed online, including running R CMD javareconf, but without success (output is below). Any advice on how to fix this issue would be much appreciated.
Among the things I tried is the solution proposed here: rJava installation fails on macOS 10.14
open macOS_SDK_headers_for_macOS_10.14.pkg```
This had worked for me with my previous Mac, but not this time.
Output of:
```sudo R CMD javareconf```
Java interpreter : /usr/bin/java
Java version : 12.0.2
Java home path : /Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home
Java compiler : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar
trying to compile and link a JNI program
detected JNI cpp flags : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin
detected JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
/usr/local/Cellar/gcc/9.1.0/bin/gcc-9 -I"/usr/local/Cellar/r/3.6.1/lib/R/include" -DNDEBUG -I/Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home/include/darwin -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/include -fPIC -g -O2 -c conftest.c -o conftest.o
/usr/local/Cellar/gcc/9.1.0/bin/gcc-9 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/Cellar/r/3.6.1/lib/R/lib -L/usr/local/Cellar/gcc/9.1.0/lib -o conftest.so conftest.o -L/Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home/lib/server -ljvm -L/usr/local/Cellar/r/3.6.1/lib/R/lib -lR -lintl -Wl,-framework -Wl,CoreFoundation
ld: library not found for -lintl
collect2: error: ld returned 1 exit status
make: *** [conftest.so] Error 1
Unable to compile a JNI program
JAVA_HOME : /Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home
Java library path:
JNI cpp flags :
JNI linker flags :
Updating Java configuration in /usr/local/Cellar/r/3.6.1/lib/R
Done.
I am having problems installing the Package packfor form source in Mac OS X Yosemite in the R software. I know that the package depends on fortran compiler, so I installed the gfortran available in CRAN but it does not affect anything. Bellow I am reproducing the error log.
please if anyone has any advice on this would be much appreciated.
Thanks in advance
install.packages("~/Downloads/packfor_0.0-8.tar", repos =
NULL,type="source")
installing source package ‘packfor’ ...
** libs clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -fPIC -Wall -mtune=core2 -g -O2 -c forward.c -o forward.o forward.c:411:3: warning: implicit declaration of function 'dgesvd_' is invalid in C99 [-Wimplicit-function-declaration]
F77_CALL(dgesvd)(&jobu, &jobvt,&size, &size,A, &size,
D,U,&size,V,&size,&work1, &lwork,&error); ^
/Library/Frameworks/R.framework/Resources/include/R_ext/RS.h:82:22:
note: expanded from macro 'F77_CALL'
define F77_CALL(x) x ## _
^ :8:1: note: expanded from here dgesvd_ ^ forward.c:421:43: warning: data argument not used by
format string [-Wformat-extra-args]
fprintf(stderr, "error in dinvG: ", error);
~~~~~~~~~~~~~~~~~~ ^
/Library/Frameworks/R.framework/Resources/include/R_ext/Error.h:51:15:
note: expanded from macro 'error'
define error Rf_error
^ 2 warnings generated. 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 packfor.so forward.o -L/Library/Frameworks/R.framework/Resources/lib
-lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2 -lgfortran -lquadmath -lm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation Warning message: In install.packages("~/Downloads/packfor_0.0-8.tar", repos = NULL, :
installation of package ‘/Users/rafael/Downloads/packfor_0.0-8.tar’
had non-zero exit status ld: warning: directory not found for option
'-L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2' ld: library not
found for -lquadmath clang: error: linker command failed with exit
code 1 (use -v to see invocation) make: *** [packfor.so] Error 1
ERROR: compilation failed for package ‘packfor’
* removing ‘/Library/Frameworks/R.framework/Versions/3.1/Resources/library/packfor’
>