R Linux error while trying to install apackage - r

I am quite new to R on Linux, and I was trying to install the package DMRcate via the BiocManager command. I kept receiving the error message that
/usr/bin/ld: cannot find -llapack: No such file or directory
/usr/bin/ld: cannot find -lblas: No such file or directory
It seems like the installation or compilation of certain dependency packages could not be carried out because of these errors.
In addition, the last line of the compilation before this error message pops up is as follows.
g++ -std=gnu++11 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o edgeR.so R_add_prior_count.o R_ave_log_cpm.o R_calculate_cpm.o R_check_poisson_bound.o R_compute_apl.o R_compute_nbdev.o R_exact_test_by_deviance.o R_fit_levenberg.o R_fit_one_group.o R_get_one_way_fitted.o R_initialize_levenberg.o R_loess_by_col.o R_maximize_interpolant.o R_process_hairpin_reads.o R_simple_good_turing.o add_prior.o adj_coxreid.o fmm_spline.o glm_levenberg.o glm_one_group.o init.o interpolator.o nbdev.o objects.o -llapack -lblas -lgfortran -lm -lquadmath -L/usr/lib/R/lib -lR
Can anyone help me with this issue? Many thanks in advance!

Related

Problem installing "nloptr" in R 4.2.2 on Ubuntu 22.04

My installation of "ggpubr" on Rstudio (based on R 4.2.2) in Ubuntu 22.04 failed because of issues in installing "nloptr". I installed NLOPT based on guides in https://nlopt.readthedocs.io/en/latest/NLopt_Installation/, but nloptr installation is still failing but with another kind of error.
Here are the last lines:
g++ -std=gnu++11 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -flto=auto -Wl,-z,relro -o nloptr.so init_nloptr.o nloptr.o test-C-API.o test-runner.o -llapack -lblas -lgfortran -lm -lquadmath -L/usr/local/lib -lnlopt -L/usr/lib/R/lib -lR
/usr/bin/ld: cannot find -llapack: No such file or directory
/usr/bin/ld: cannot find -lblas: No such file or directory
/usr/bin/ld: cannot find -lgfortran: No such file or directory
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’
Any help is appreciated.
Best,
Amir
The comments by #jay.sf and myself give you the narrowest answer: you attempt to build from source, and compiling and linking requires the so-called -dev packages. So install r-base-dev.
Looking beyond this for a second though, you are on Ubuntu 22.04 and you have r-cran-nloptr inside the distribution too (albeit an older version). So sudo apt install r-cran-nloptr works as well.
And since this summer there is r2u which gives you (on Ubuntu 20.04 and Ubuntu 22.04) every CRAN package as an Ubuntu binary and is generally current. It is easy to set up and the command install.packages("ggpubr") would then reliably and quickly install the package and all its dependencies from binaries.

Linking error for RInside on Mac OS X 11.6 (Big Bur): pcre2-8 library not found

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.

Compilation error of R package

I want to compile hsphase package (R package available in CRAN).
I used this command in R install.packages("hsphase").
I have got the following errors:
g++ -m64 -shared -L/usr/lib64/R/lib -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -o hsphase.so FastDist.o MAF.o Ohd.o TypeConversion.o block.o block4Phase.o co.o diag.o hsp.o main.o memory.o oh.o swDetect.o [1] 0 -L/usr/lib64/R/lib -lRlapack -L/usr/lib64/R/lib -lRblas -lgfortran -lm -lquadmath -fopenmp -L/usr/lib64/R/lib -lR
g++: error: [1]: No such file or directory
g++: error: 0: No such file or directory
/usr/share/R/make/shlib.mk:6: recipe for target 'hsphase.so' failed
make: *** [hsphase.so] Error 1
ERROR: compilation failed for package ‘hsphase’
* removing ‘/home/mhf/R/x86_64-redhat-linux-gnu-library/3.3/hsphase’
The downloaded source packages are in
‘/tmp/RtmpYukJQa/downloaded_packages’
Warning message:
In install.packages("hsphase") :
installation of package ‘hsphase’ had non-zero exit status
I am using fedora 24.
The g++ version:
gcc version 6.1.1 20160621 (Red Hat 6.1.1-3) (GCC)
Please check the link flag:
what is this:
[1] 0
I comment this line in the scr/Makevars file:
#PKG_LIBS = `$(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()"` $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) $(SHLIB_OPENMP_CXXFLAGS)
Now, I can compile the package.

ld fails to find openssl, even though its present

I am trying to install RCurl in R 3.2.0 in RHEL 5.
install.packages("RCurl")
At the end it failed because
gcc -std=gnu99 -shared -L/home/gowthan/Downloads/R-3.2.0/lib -L/usr/local/lib64 -o RCurl.so base64.o curl.o curlInit.o curl_base64.o enums.o json.o memoryManagement.o myUTF8.o -L/local/p4clients/pkgbuild-5R4zB/workspace/build/Curl/Curl-7.18.1.155.6782/RHEL5_64/DEV.STD.PTHREAD/build/private/curl/install/lib -lcurl -L/opt/brazil-pkg-cache/packages/Fbopenssl/Fbopenssl-0.0.4.504.7765/RHEL5_64/DEV.STD.PTHREAD/build/lib -lfbopenssl -L/local/p4clients/pkgbuild-5R4zB/workspace/build/Curl/Curl-7.18.1.155.6782/RHEL5_64/DEV.STD.PTHREAD/build/private/tmp/brazil-path/[Openssl]lib.libfarm/lib -L/local/p4clients/pkgbuild-k5Vrj/workspace/build/Libxml2/Libxml2-2.7.8.334.176/RHEL5_64/DEV.STD.PTHREAD/build/private/libxml2/install/lib -lxml2 -lz -lm -L/home/gowthan/Downloads/R-3.2.0/lib -lR
/usr/bin/ld: cannot find -lfbopenssl
collect2: ld returned 1 exit status
make: *** [RCurl.so] Error 1
ERROR: compilation failed for package \u2018RCurl\u2019
The line it fails is : /usr/bin/ld: cannot find -lfbopenssl. But, I have openssl at /usr/bin/openssl. How do I make 'ld' use it?
Regarding openssl-devel, yum install openssl-devel says that I already have the latest package. But "where openssl-devel" says that its not found! Is something wrong here?
Is fbopenssl same as openssl?

Installing knncat

I am using R in Ubuntu 10.04.
I need to understand the documentation.
Installing knncat I get this error message:
gcc -I/usr/share/R/include -I . -DUSE_R_ALLOC -DCALL_FROM_R -fpic
-std=gnu99 -O3 -pipe -g -c ranlib.c -o ranlib.o gcc -I/usr/share/R/include -I . -DUSE_R_ALLOC -DCALL_FROM_R -fpic -std=gnu99 -O3 -pipe -g -c utilsR.c -o utilsR.o gcc -shared -o knncat.so com.o dodisc.o donn.o donnwrap.o dsort.o linpack.o matrix.o
objective.o ords.o ranlib.o utilsR.o -llapack -lblas -lgfortran -lm
-L/usr/lib/R/lib -lR /usr/bin/ld: cannot find -llapack collect2: ld returned 1 exit status make: *** [knncat.so] Error 1 ERROR:
compilation failed for package ‘knncat’
In the documentation I find this recomendation:
Provision is made for using an external LAPACK library, principally to
cope with BLAS libraries which contain a copy of LAPACK (such as sunperf
on Solaris, vecLib on OS X and ACML on ‘ix86’/‘x86_64’ Linux)
If it is mandatory (?), I should use this code:
--with-lapack="-L/path/to/libs -llapack -lcblas"
But where? I am using the standard installation of packages in R.
install.packages('knncat')
I am not sure of:
Is it mandatory to install lapack? I do have BLAS + LAPACK.
How to install a package without using install.packages()?
which are the choices I have now?
Please install the r-base-dev package, which will take care of the -dev packages for LAPACK and BLAS as well.
It was an old version of R. Even when I did upgrade, it does not fixed.
I followed this orders: from http://ubuntuforums.org/showthread.php?t=377323
sudo aptitude install r-base r-recommended
In R
install.packages('knncat')
Now it is working!

Resources