R package installation - R CMD check throws ERROR: Installation Failed - r

I'm having trouble getting a package that I have written to install (on a Windows 10 machine).
I'm running R CMD build packagename (no errors), then R CMD check packagename_0.1.0.tar.gz (or R CMD INSTALL packagename)
After a number of successful log entries, the output reads
* checking whether package 'packagename' can be installed ...Warning: running command '"C:/PROGRA~1/R/R-3.4.0/bin/x64/Rcmd.exe" INSTALL -l
"C:/Work/parsimony_inapp/packagename.Rcheck" --no-html
"C:\Work\PARSIM~1\packagename.Rcheck\00_pkg_src\packagename"' had status 1
ERROR
Installation failed.
00install.out reports the error:
C:/MinGW/bin/gcc -shared -s -static-libgcc -o packagename.dll tmp.def fitch.o reorder.o -Ld:/Compiler/gcc-4.9.3/local330/lib/x64 -Ld:/Compiler/gcc-
4.9.3/local330/lib -LC:/PROGRA~1/R/R-3.4.0/bin/x64 -lR
C:/PROGRA~1/R/R-3.4.0/bin/x64/R.dll: file not recognized: File format not
recognized
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'packagename'
Oddly, I can install the package from GitHub using devtools::github_install('path/to/package').
Advice I've found elsewhere doesn't help:
setwd() in Rprofile - not present
Set R_WIN_NO_JUNCTIONS - no effect
I've updated to the latest version of R (3.4.0), RTools (34) and Cygwin, and checked that my PATH environment variable contains (in order) C:\Rtools\bin; C:\Rtools\mingw_32\bin; C:\Program Files\R\R-3.4.0\bin; C:\Program Files\R\R-3.4.0\bin\x64.
I've tried including and excluding C:\cygwin64\bin and C:\MinGW\msys\1.0\bin from the path, and have tried installations of Rtools with and without the Cygwin dlls, and have tried uninstalling Cygwin completely.

Related

Cannot install nloptr (R 4.0.3, Ubuntu 20.04)

I tried to install nloptr on R 4.0.3, however I get this error:
/usr/bin/ld: /usr/local/lib/libnlopt.a(general.o): relocation R_X86_64_TPOFF32 against `nlopt_srand_called' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/lib/libnlopt.a(mt19937ar.o): relocation R_X86_64_TPOFF32 against `mti' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/lib/libnlopt.a(timer.o): relocation R_X86_64_TPOFF32 against `start_inited.4301' can not be used when making a shared object; recompile with -fPIC
collect2: error: ld returned 1 exit status
make: *** [/usr/share/R/share/make/shlib.mk:10: nloptr.so] Error 1
ERROR: compilation failed for package ‘nloptr’
* removing ‘/home/giovanni/R/x86_64-pc-linux-gnu-library/4.0/nloptr’
Warning in install.packages :
installation of package ‘nloptr’ had non-zero exit status
Can someone point me to a solution?
Thanks in advance.
The latest (2.6.2) package of libnlopt-dev is broken in Ubuntu 20, for some reason it is compiled into a static library (.so shared object is missing)
I faced the similar problem a couple of days ago. The quick fix is to download NLOPT fron Github and compile it yourself
https://nlopt.readthedocs.io/en/latest/NLopt_Installation/
At least, it worked for me.
I had a slightly related issue with this package, apt install cmake which was suggested by cli itself fixed the issue.
I also failed to install the nloptr but had another error.
g++: error: nlopt/lib/libnlopt.a: No such file or directory
I followed others suggestion to install the nlopt first as described in nlopt website. The installation process was
mkdir build
cd build
cmake ..
make
sudo make install
But I found the cmake version which nlopt needed should be higher than 3. The default cmake in my computer was version 2.8.12.2 which was /usr/bin/cmake. So I installed cmake version 3.24.2 in my home directory and compiled the nlopt using absolute path of cmake as ~/software/install/cmake-3.24.2-linux-x86_64/bin/cmake ... And I used sudo to install the nlopt in the computer. I could see the libnlopt.so libnlopt.so.0 libnlopt.so.0.11.1 files in /usr/local/lib64
When I went back to install the nloptr in R. It still failed. I found the cmake failure in the output information of installation. So I add the cmake(version 3.24.2) to my PATH in .bashrc file and then I installed the nloptr successfully.

Where should I search for the installed R packages by conda?

I am installing r packages using conda. It works fine when I use this example format
"conda install -c r r-scales --name condaenv"
But when I want to define installtion directory using --prefix
conda install -c r r-scales --prefix=/opt/local
the package "scale" is installed but I cannot find it in the directory I expect to be
"/opt/local/lib/R/library"
. It is weird because when I try to reinstall this package it says
All requested packages already installed.
that means this package is already installed in defined path. BUT WHERE?
I also try using
conda list
But I cannot find "scales" among installed packages.
UPDATE:
I also tried to use install.packages("scales), but I ran into this error
/opt/anaconda/bin/x86_64-conda_cos6-linux-gnu-ld: cannot find -lm
collect2: error: ld returned 1 exit status make: ***
[/raid60/raid2/opt/local/lib/R/share/make/shlib.mk:6: scales.so] Error
1 ERROR: compilation failed for package ?scales?
* removing ?/raid60/raid2/opt/local/lib/R/library/scales?

R can not install packages on centos 6.5

I installed R on centos 6.5 gcc version 4.4.7 g++ version 4.4.7
when I run R and try to install packages
install.packages("fArma")
It give the following error
gcc: /builddir/build/BUILD/R-3.3.0/zlib-1.2.8/target/usr/lib64/libz.a: No such file or directory
gcc: /builddir/build/BUILD/R-3.3.0/bzip2-1.0.6/target/usr/lib64/libbz2.a: No such file or directory
gcc: /builddir/build/BUILD/R-3.3.0/xz-5.2.2/target/usr/lib64/liblzma.a: No such file or directory
gcc: /builddir/build/BUILD/R-3.3.0/pcre-8.38/target/usr/lib64/libpcre.a: No such file or directory
gcc: /builddir/build/BUILD/R-3.3.0/curl-7.48.0/target/usr/lib64/libcurl.a: No such file or directory
gcc: /builddir/build/BUILD/R-3.3.0/zlib-1.2.8/target/usr/lib64/libz.a: No such file or directory
gcc: /builddir/build/BUILD/R-3.3.0/bzip2-1.0.6/target/usr/lib64/libbz2.a: No such file or directory
gcc: /builddir/build/BUILD/R-3.3.0/xz-5.2.2/target/usr/lib64/liblzma.a: No such file or directory
gcc: /builddir/build/BUILD/R-3.3.0/pcre-8.38/target/usr/lib64/libpcre.a: No such file or directory
gcc: /builddir/build/BUILD/R-3.3.0/curl-7.48.0/target/usr/lib64/libcurl.a: No such file or directory
make: *** [gss.so] Error 1
ERROR: compilation failed for package âgssâ
* removing â/usr/lib64/R/library/gssâ
ERROR: dependency âgssâ is not available for package âfBasicsâ
* removing â/usr/lib64/R/library/fBasicsâ
ERROR: dependency âfBasicsâ is not available for package âfArmaâ
* removing â/usr/lib64/R/library/fArmaâ
I checked if these lib's exist in /usr/lib64/ and i found them but with the extension so
And it's not issue of missing libraries, I know because i checked the lib in /usr/lib64 with another working machine and it's the same.
Any idea what the problem could be?
The reason that your package is failing to build is because GCC is not able to compile the software and might need additional packages to do so.
I would suggest that you install the entire c development suite for yum.
You can do this with
You will first want to run:
sudo yum groupinstall 'Development Tools'
Do note the version numbers in the pathnames: zlib-1.2.8, bzip2-1.0.6, xz-5.2.2 etc. CentOS has zlib-1.2.3-29, bzip2-1.0.5-7 and xz-4.999.9-0.5.beta.20091007git.
Your build script apparently tries to use libraries that should be present in your source package, but for some reason they aren't there. The build script does not seem to use system (CentOS) provided libraries.
This LINK should solve your problem hopefully.

*.o: File format not recognized on Windows 7

I wrote an R package called arbintools for some work-related data analysis and put it on Github. I wrote it and have been using it on my Mac for a while without issue; Today, I tried to install the dev-1 branch on a Windows 7 laptop and something related to compiling some Rcpp functions seems to go wrong:
devtools::install_github("mjlacey/arbintools", ref = "dev1")
I get this:
Downloading GitHub repo mjlacey/arbintools#dev1
from URL https://api.github.com/repos/mjlacey/arbintools/zipball/dev1
Installing arbintools
"C:/PROGRA~1/R/R-33~1.0/bin/x64/R" --no-site-file --no-environ --no-save \
--no-restore --quiet CMD INSTALL \
"C:/Users/matla332.USER/AppData/Local/Temp/Rtmp8WWkKC/devtools124c45026af1/mjlacey-arbintools-41dc363" \
--library="C:/Users/matla332.USER/Documents/R/win-library/3.3" \
--install-tests
* installing *source* package 'arbintools' ...
** libs
*** arch - i386
C:\Rtools\mingw_32\bin\nm.exe: RcppExports.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: Rcpp_functions.o: File format not recognized
c:/Rtools/mingw_32/bin/g++ -shared -s -static-libgcc -o arbintools.dll tmp.def RcppExports.o Rcpp_functions.o -Ld:/Compiler/gcc-4.9.3/local330/lib/i386 -Ld:/Compiler/gcc-4.9.3/local330/lib -LC:/PROGRA~1/R/R-33~1.0/bin/i386 -lR
RcppExports.o: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'arbintools'
* removing 'C:/Users/matla332.USER/Documents/R/win-library/3.3/arbintools'
* restoring previous 'C:/Users/matla332.USER/Documents/R/win-library/3.3/arbintools'
Error: Command failed (1)
Installing other packages requiring some compilation (like dplyr) worked fine. I also updated R on my Mac to the same version (3.3.0) and reinstalled the package successfully, it's just on the Windows PC it doesn't work. This is beyond my understanding, if anyone has a suggestion or solution I'd be very grateful.
The issue is the .so and .o files are only viable with the same architecture e.g. OS X is 64 bit and Windows is 32bit (mingw_32). Please remove them from dev-1/src and then you should be good to go. These files are automatically built on package install as they are the result of using a compiler.
After they are removed, try to create a .gitignore file with the following:
src/*.o
src/*.so
src/*.dll
This will make OS specific files not selectable for staging and, in turn, commits.
As a general rule of thumb, only keep .cpp or .h files within /src while using Rcpp.

gcc error when installing Statnet package

Installing statnet on mac 10.10.3 with R 3.2.x (RStudio 0.99.441).
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 -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [latentnet.so] Error 1
ERROR: compilation failed for package ‘latentnet’
* removing ‘/Library/Frameworks/R.framework/Versions/3.2/Resources/library/latentnet’
Warning in install.packages :
installation of package ‘latentnet’ had non-zero exit status
ERROR: dependency ‘latentnet’ is not available for package ‘statnet’
* removing ‘/Library/Frameworks/R.framework/Versions/3.2/Resources/library/statnet’
Warning in install.packages :
installation of package ‘statnet’ had non-zero exit status
I tried updating XCode/Command Line Tools. Also tried not installing dependencies. I have been able to install other packages, such as ergm and sna.
It looks like the install is looking for the GCC folder and not finding it.
whereis gcc
reveals that my gcc is in /usr/bin/gcc
It looks like the install is looking for it in /usr/local/lib/gcc/
Is there a way to fix this?
This is a compilation error that you only get if you are trying to install packages from source, or when a package requires a library to be compiled from source. Normally, if you don’t use the latest version of R, you can install statnet from binary and thus R won’t have to compile the source package.
The version you are mentioning at the beginning of your message (0.99.441) is the version of your R-Studio, and not R. The version of your R is 3.2.x (Hence its address in the Library folder: /Library/Frameworks/R.framework/Versions/3.2/Resources…). Before trying to fix the compilation error you may want to try to roll back your R to a version like 3.1.2 or 3.1.3 on which you can probably download and install statnet in binary format.
For the compiler, my guess is that even if you fix the address of your gcc with a symlink, you will still get an error about gfortran or the version of gcc. Once I solved this issue by installing R and the right version of gcc through Homebrew, but right now I don’t have the possibility to try the solution and tell you exactly how.
My experience (on Yosemite) is that if you use 3.1.2 or 3.1.3, even if there is need for compilation, the error with gcc won’t occur.
sudo mkdir /usr/bin/lib && sudo ln -s /usr/bin/gcc /usr/bin/lib/gcc
Creates a new directory in /usr/bin called `lib' and creates a symbolic link to gcc in that new directory.
If that doesn't fix the error, you can undo it with:
sudo rm -i /usr/bin/lib/gcc && sudo rm -id /usr/bin/lib

Resources