Search code examples
rcompiler-errorsfedoracran

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


Solution

  • 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.