I am trying to install R’s plyr package. Here is the error message:
* installing *source* package ‘plyr’ ...
** package ‘plyr’ successfully unpacked and MD5 sums checked
** libs
clang++ -I/opt/R-3.4.1/include -DNDEBUG -I"/home/isomorphismes/R/i686-pc-linux-gnu-library/3.4/Rcpp/include" -I/usr/local/include -fpic -I/opt/boost_1_61_0/boost -c RcppExports.cpp -o RcppExports.o
clang -I/opt/R-3.4.1/include -DNDEBUG -I"/home/cd/R/i686-pc-linux-gnu-library/3.4/Rcpp/include" -I/usr/local/include -fpic -g -O2 -flto -c loop_apply.c -o loop_apply.o
clang++ -I/opt/R-3.4.1/include -DNDEBUG -I"/home/isomorphismes/R/i686-pc-linux-gnu-library/3.4/Rcpp/include" -I/usr/local/include -fpic -I/opt/boost_1_61_0/boost -c split-numeric.cpp -o split-numeric.o
clang++ -shared -L/usr/local/lib -o plyr.so RcppExports.o loop_apply.o split-numeric.o
loop_apply.o: file not recognized: File format not recognized
clang: error: linker command failed with exit code 1 (use -v to see invocation)
/opt/R-3.4.1/share/make/shlib.mk:6: recipe for target 'plyr.so' failed
make: *** [plyr.so] Error 1
ERROR: compilation failed for package ‘plyr’
* removing ‘/home/cd/R/i686-pc-linux-gnu-library/3.4/plyr’
The *.o files are in /opt/plyr/src, from github.com/hadley/plyr. They look like this on my system:
i#scheherezade:/opt/plyr/src$ file *o
loop_apply.o: LLVM IR bitcode
RcppExports.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped
split-numeric.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped
In case you didn't know, -flto specifies link time optimization, and has been added by R. How did you manage to end up with such a mis-configured R install?
Adding -flto to the link command may work? Or remove it from the loop_apply compilation line. If either of those works, you need to fix your R install.
Compiling with -flto using clang requires (on Ubuntu) installing the llvm-dev package. Otherwise, the linker is unable to handle -flto object files.
apt-get install clang-10 llvm-10-dev
Now the linking should succeed.
Related
I am encountering the same type of problem as described in this question. However, in accordance with the answer, I have updated my R (version 4.1.3) and CMake (version 3.12.3) and I still can't seem to install the package. I am running CentOS 7.
Here is the log:
> install.packages("nloptr")
Installing package into ‘/home/userr/R/x86_64-pc-linux-gnu-library/4.1’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/nloptr_2.0.0.tar.gz'
Content type 'application/x-gzip' length 2219414 bytes (2.1 MB)
==================================================
downloaded 2.1 MB
* installing *source* package ‘nloptr’ ...
** package ‘nloptr’ successfully unpacked and MD5 sums checked
** using staged installation
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ -std=gnu++11 accepts -g... yes
checking how to run the C++ preprocessor... g++ -std=gnu++11 -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether g++ -std=gnu++11 accepts -g... (cached) yes
checking for pkg-config... /usr/bin/pkg-config
checking if pkg-config knows NLopt... no
using NLopt via local cmake build on x86_64
set CMAKE_BIN=/usr/local/bin/cmake
set CC=gcc -std=gnu11
set CFLAGS=-I/usr/local/include -fpic -g -O2
set CXX=g++
set CXXFLAGS=-std=gnu++11 -I/usr/local/include -fpic -g -O2
set LDFLAGS=-L/usr/local/lib
CMake Error: The source directory "/tmp/RtmpVJjt9p/R.INSTALL27cf4036808b/nloptr/src/nlopt-build" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
Error: /tmp/RtmpVJjt9p/R.INSTALL27cf4036808b/nloptr/src/nlopt-build is not a directory
CMake Error: The source directory "/tmp/RtmpVJjt9p/R.INSTALL27cf4036808b/nloptr/src/nlopt" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
cp: cannot stat 'nlopt/include/*': No such file or directory
configure: creating ./config.status
config.status: creating src/Makevars
** libs
gcc -std=gnu11 -I"/opt/R/4.1.3/lib/R/include" -DNDEBUG -I../inst/include -I'/home/userr/R/x86_64-pc-linux-gnu-library/4.1/testthat/include' -I/usr/local/include -fpic -g -O2 -c init_nloptr.c -o init_nloptr.o
gcc -std=gnu11 -I"/opt/R/4.1.3/lib/R/include" -DNDEBUG -I../inst/include -I'/home/userr/R/x86_64-pc-linux-gnu-library/4.1/testthat/include' -I/usr/local/include -fpic -g -O2 -c nloptr.c -o nloptr.o
g++ -std=gnu++11 -I"/opt/R/4.1.3/lib/R/include" -DNDEBUG -I../inst/include -I'/home/userr/R/x86_64-pc-linux-gnu-library/4.1/testthat/include' -I/usr/local/include -fpic -g -O2 -c test-C-API.cpp -o test-C-API.o
g++ -std=gnu++11 -I"/opt/R/4.1.3/lib/R/include" -DNDEBUG -I../inst/include -I'/home/userr/R/x86_64-pc-linux-gnu-library/4.1/testthat/include' -I/usr/local/include -fpic -g -O2 -c test-runner.cpp -o test-runner.o
g++ -std=gnu++11 -shared -L/opt/R/4.1.3/lib/R/lib -L/usr/local/lib -o nloptr.so init_nloptr.o nloptr.o test-C-API.o test-runner.o -L/opt/R/4.1.3/lib/R/lib -lRlapack -L/opt/R/4.1.3/lib/R/lib -lRblas -lgfortran -lm -lquadmath -Lnlopt/lib -lnlopt -L/opt/R/4.1.3/lib/R/lib -lR
installing to /home/userr/R/x86_64-pc-linux-gnu-library/4.1/00LOCK-nloptr/00new/nloptr/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
converting help for package ‘nloptr’
finding HTML links ... done
auglag html
bobyqa html
ccsaq html
check.derivatives html
cobyla html
crs2lm html
direct html
is.nloptr html
isres html
lbfgs html
mlsl html
mma html
neldermead html
newuoa html
nl.grad html
nl.opts html
nloptr-package html
nloptr html
nloptr.get.default.options html
nloptr.print.options html
print.nloptr html
sbplx html
slsqp html
stogo html
tnewton html
varmetric html
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘nloptr’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/home/userr/R/x86_64-pc-linux-gnu-library/4.1/00LOCK-nloptr/00new/nloptr/libs/nloptr.so':
libnlopt.so.0: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/userr/R/x86_64-pc-linux-gnu-library/4.1/nloptr’
Warning in install.packages :
installation of package ‘nloptr’ had non-zero exit status
The downloaded source packages are in
‘/tmp/Rtmp3kX1wu/downloaded_packages’
I don't know what could be causing the error, but my guess is that this line from the above log is the most relevant:
CMake Error: The source directory "/tmp/RtmpVJjt9p/R.INSTALL27cf4036808b/nloptr/src/nlopt-build" does not exist.
I would be thankful for all the help as I don't know much about Linux systems.
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 am running MRO 3.5.0 on Win10, and trying to install a package image.CannyImage from bnosac/image on the github. But it keeps reporting fatal errors as following.
* installing *source* package 'image.CannyEdges' ...
** libs
c:/Rtools/mingw_64/bin/g++ -m64 -I"C:/PROGRA~1/MICROS~1/ROPEN~1/R-35~1.0/include" -DNDEBUG -I"C:/Users/eric1/Documents/R/win-library/3.5/Rcpp/include" -I"C:/swarm/workspace/External-R-3.5.0/vendor/extsoft/include" -O2 -Wall -mtune=core2 -c RcppExports.cpp -o RcppExports.o
c:/Rtools/mingw_64/bin/gcc -m64 -I"C:/PROGRA~1/MICROS~1/ROPEN~1/R-35~1.0/include" -DNDEBUG -I"C:/Users/eric1/Documents/R/win-library/3.5/Rcpp/include" -I"C:/swarm/workspace/External-R-3.5.0/vendor/extsoft/include" -O2 -Wall -std=gnu99 -mtune=core2 -c adsf.c -o adsf.o
c:/Rtools/mingw_64/bin/g++ -m64 -I"C:/PROGRA~1/MICROS~1/ROPEN~1/R-35~1.0/include" -DNDEBUG -I"C:/Users/eric1/Documents/R/win-library/3.5/Rcpp/include" -I"C:/swarm/workspace/External-R-3.5.0/vendor/extsoft/include" -O2 -Wall -mtune=core2 -c rcpp_canny.cpp -o rcpp_canny.o
In file included from rcpp_canny.cpp:13:0:
canny.h:8:19: fatal error: fftw3.h: No such file or directory
#include <fftw3.h>
^
compilation terminated.
make: *** [C:/PROGRA~1/MICROS~1/ROPEN~1/R-35~1.0/etc/x64/Makeconf:215: rcpp_canny.o] Error 1
ERROR: compilation failed for package 'image.CannyEdges'
* removing 'C:/Users/eric1/Documents/R/win-library/3.5/image.CannyEdges'
In R CMD INSTALL
Installation failed: Command failed (1)
^
compilation terminated.
Google says I can solve the issue by sudo apt-get remove libfftw3-dev. Unfortunately, I am on Windows, and some advised, apply lib /machine:i386 /def:libfftw3-3.def on cmd mode. Ouch, there is no such command or file called lib.exe on Win10.
Please advise, how I can solve this issue on my Win10+MRO system. Thanks.
Even though this question is already a bit old:
By now (Feb 2020) there are precompiled packages available that work also under Windows:
Canny Edges - Package
and more general:
List of all available packages
I have tried installing them and (at least for me) it worked.
I am very new to R language. Being an admin I am setting up an rserver and installing the required packages for my use of this R server with SAP HANA 1.0.
The fundamental problem here is when i am installing the rcpp.0.12.16 and getting the below error. g++ is 4.8-6.189.
Are there an incompatibilities witht the OS version R version and rccp package i am using? Please help resolving this issue.
> setwd("/Media/R/R_indep_pack")
> install.packages("Rcpp_0.12.16.tar.gz",repos = NULL, type="source")
* installing *source* package ‘Rcpp’ ...
** package ‘Rcpp’ successfully unpacked and MD5 sums checked
** libs
g++ -I/usr/local/lib64/R/include -DNDEBUG -I../inst/include/ -
I/usr/local/include -fPIC -c Date.cpp -o Date.o
g++ -I/usr/local/lib64/R/include -DNDEBUG -I../inst/include/ -
I/usr/local/include -fPIC -c Module.cpp -o Module.o
g++ -I/usr/local/lib64/R/include -DNDEBUG -I../inst/include/ -
I/usr/local/include -fPIC -c Rcpp_init.cpp -o Rcpp_init.o
g++ -I/usr/local/lib64/R/include -DNDEBUG -I../inst/include/ -
I/usr/local/include -fPIC -c api.cpp -o api.o
g++ -I/usr/local/lib64/R/include -DNDEBUG -I../inst/include/ -
I/usr/local/include -fPIC -c attributes.cpp -o attributes.o
g++ -I/usr/local/lib64/R/include -DNDEBUG -I../inst/include/ -
I/usr/local/include -fPIC -c barrier.cpp -o barrier.o
g++ -L/usr/local/lib64/R/lib -L/usr/local/lib64 -o Rcpp.so Date.o Module.o
Rcpp_init.o api.o attributes.o barrier.o -L/usr/local/lib64/R/lib -lR
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../lib64/crt1.o: In function
`_start':
/home/abuild/rpmbuild/BUILD/glibc-2.22/csu/../sysdeps/x86_64/start.S:114:
undefined reference to `main'
collect2: error: ld returned 1 exit status
/usr/local/lib64/R/share/make/shlib.mk:6: recipe for target 'Rcpp.so' failed
make: *** [Rcpp.so] Error 1
ERROR: compilation failed for package ‘Rcpp’
* removing ‘/usr/local/lib64/R/library/Rcpp’
Warning message:
In install.packages("Rcpp_0.12.16.tar.gz", repos = NULL, type = "source") :
installation of package ‘Rcpp_0.12.16.tar.gz’ had non-zero exit status
>
Your linker is looking for a main function since it is not told to build a shared library:
g++ -L/usr/local/lib64/R/lib -L/usr/local/lib64 -o Rcpp.so Date.o Module.o
Rcpp_init.o api.o attributes.o barrier.o -L/usr/local/lib64/R/lib -lR
Here a -shared is missing from the command line. The command line flags used here are defined via the Makevars file:
$ grep SHLIB.*LDFLAGS $(R RHOME)/etc/Makeconf
SHLIB_CXXLDFLAGS = -shared
SHLIB_CXX98LDFLAGS = -shared
SHLIB_CXX11LDFLAGS = -shared
SHLIB_CXX14LDFLAGS = -shared
SHLIB_CXX17LDFLAGS = -shared
SHLIB_FCLDFLAGS = -shared
SHLIB_LDFLAGS = -shared# $(CFLAGS) $(CPICFLAGS)
SHLIB_LINK = $(SHLIB_LD) $(SHLIB_LDFLAGS) $(LIBR0) $(LDFLAGS)
SHLIB_CXX1XLDFLAGS = -shared
Either these are incorrectly set on your system or you are overriding them via ~/.R/Makevars.
In ubuntu, in such situation, I would search for
apt search rcpp # search in central repository for \
# packages for R packages
In this case, this leads to 'r-cran-rcpp' package which I then install with
sudo apt install r-cran-rcpp
(such packages from 'r-cran-' help, because they install for you the further dependencies in the system - which are often dependencies outside of R - automatically for you. E.g. some packages require java or some other system libraries.).
Similarly, you have to search in rpm or yast2 repos for rcpp packages.
I found googling http://rpmfind.net/linux/rpm2html/search.php?query=R-Rcpp
or http://rpm.pbone.net/index.php3/stat/4/idpl/33595438/dir/opensuse/com/R-RcppArmadillo-0.4.450.1.0-2.38.i586.rpm.html
Or: if you are using conda:
conda install -c r r-rcpp
would definitely help ...
If you don't know conda: This tutorial is super!
https://www.youtube.com/watch?v=YJC6ldI3hWk
Just spend 11 minutes and you will be able to use conda!
(With conda, you can install several R versions with all their packages in parallel in your system - sometimes you need that because some versions are not compativle with some R packages - conda creates for you different local environments within which you can install programs with all their specific dependencies. And you can switch between the environments.)
I definitely recommend you to use conda. Because this solves many package dependency problems.
I want to install Rcpp using install.packages("Rcpp"), but it failed.
The error message:
* installing *source* package ‘Rcpp’ ...
** package ‘Rcpp’ successfully unpacked and MD5 sums checked
** libs
g++ -I/usr/local/lib64/R/include -DNDEBUG -I../inst/include/ -I/usr/local/include -fpic -g -O2 -c Date.cpp -o Date.o
g++ -I/usr/local/lib64/R/include -DNDEBUG -I../inst/include/ -I/usr/local/include -fpic -g -O2 -c Module.cpp -o Module.o
g++ -I/usr/local/lib64/R/include -DNDEBUG -I../inst/include/ -I/usr/local/include -fpic -g -O2 -c Rcpp_init.cpp -o Rcpp_init.o
g++ -I/usr/local/lib64/R/include -DNDEBUG -I../inst/include/ -I/usr/local/include -fpic -g -O2 -c api.cpp -o api.o
g++ -I/usr/local/lib64/R/include -DNDEBUG -I../inst/include/ -I/usr/local/include -fpic -g -O2 -c attributes.cpp -o attributes.o
g++ -I/usr/local/lib64/R/include -DNDEBUG -I../inst/include/ -I/usr/local/include -fpic -g -O2 -c barrier.cpp -o barrier.o
g++ -shared -L/usr/local/lib64 -o Rcpp.so Date.o Module.o Rcpp_init.o api.o attributes.o barrier.o
installing to /home/sethbrin/R/x86_64-redhat-linux-gnu-library/3.1/Rcpp/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/home/sethbrin/R/x86_64-redhat-linux-gnu-library/3.1/Rcpp/libs/Rcpp.so':
/home/sethbrin/R/x86_64-redhat-linux-gnu-library/3.1/Rcpp/libs/Rcpp.so: undefined symbol: _ZNSt15basic_streambufIcSt11char_traitsIcEE7seekoffExSt12_Ios_SeekdirSt13_Ios_Openmode
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/sethbrin/R/x86_64-redhat-linux-gnu-library/3.1/Rcpp’
The downloaded source packages are in
‘/tmp/Rtmp6PKB8N/downloaded_packages’
Warning message:
In install.packages("Rcpp") :
installation of package ‘Rcpp’ had non-zero exit status
Then I use
c++fit _ZNSt15basic_streambufIcSt11char_traitsIcEE7seekoffExSt12_Ios_SeekdirSt13_Ios_Openmode
std::basic_streambuf<char, std::char_traits<char> >::seekoff(long long, std::_Ios_Seekdir, std::_Ios_Openmode)
I have searched for some solutions for that. It seems that it is because of the gcc version. But I don't know how to change the gcc version that R uses to compile Rcpp package.
CRAN tests Rcpp just like any other of the (by now) 6700+ package.
You can see the aggregate test report and the test setups includes two Fedora-based machines:
one fedora setup using clang and
one fedora setup using g++.
As such your problems are possibly local, or simply due to using an older setup. In which case the Archive section gives you access to an older version.
I've encountered a similar problem.
And after some searches, here are the solutions to alter the compiler:
1. If you have the root privilege:
I found that the Makeconf file in R directory actually sets all the information that is needed for compilation.
To find the path to it, echo which R in the command line.
e.g. I got like:
/data/apps/R/3.1.2/bin/R
And then the file is in:
/data/apps/R/3.1.2/lib64/R/etc/Makeconf
then sudo edit the file on line CC = XXX and maybe more relative lines.
Problem solved!
2. If you only have local user privilege.
Add your own configurations to ~/.R/Makevars
However, #Dirk is probably right.
For me, I finally solved my problem by adding -Doff_t=__off_t to CFLAGS (My problem was error: unknown type name 'off_t'). And I got the halted error when I manually altered parts of the compilers...