安装R软件包时出错

时间:2019-09-30 10:26:37

标签: r solaris rcpp

在将R软件包安装到solaris服务器时,出现以下错误:

“ / R-3.6.1 / R-3.6.1 / include”位于我们的服务器中,在安装软件包时,某些脚本在内部执行并寻找"I/R-3.6.1/R-3.6.1/include",但找不到该脚本。

I"/R-3.6.1/R-3.6.1/include" -DNDEBUG -I../inst/include/  -I/usr/local/include  -KPIC   -c api.cpp -o api.o
sh: I/R-3.6.1/R-3.6.1/include: not found

make: Fatal error: Command failed for target `Rcpp.so'
ERROR: compilation failed for package 'Rcpp'

完整的install.packages()输出:

 installing *source* package 'Rcpp' ...
** package 'Rcpp' successfully unpacked and MD5 sums checked
** using staged installation
** libs
I"/R-3.6.1/R-3.6.1/include" -DNDEBUG -I../inst/include/  -I/usr/local/include  -KPIC   -c api.cpp -o api.o
sh: I/R-3.6.1/R-3.6.1/include: not found
*** Error code 127 (ignored)
I"/R-3.6.1/R-3.6.1/include" -DNDEBUG -I../inst/include/  -I/usr/local/include  -KPIC   -c attributes.cpp -o attributes.o
sh: I/R-3.6.1/R-3.6.1/include: not found
*** Error code 127 (ignored)
I"/R-3.6.1/R-3.6.1/include" -DNDEBUG -I../inst/include/  -I/usr/local/include  -KPIC   -c barrier.cpp -o barrier.o
sh: I/R-3.6.1/R-3.6.1/include: not found
*** Error code 127 (ignored)
I"/R-3.6.1/R-3.6.1/include" -DNDEBUG -I../inst/include/  -I/usr/local/include  -KPIC   -c date.cpp -o date.o
sh: I/R-3.6.1/R-3.6.1/include: not found
*** Error code 127 (ignored)
I"/R-3.6.1/R-3.6.1/include" -DNDEBUG -I../inst/include/  -I/usr/local/include  -KPIC   -c module.cpp -o module.o
sh: I/R-3.6.1/R-3.6.1/include: not found
*** Error code 127 (ignored)
I"/R-3.6.1/R-3.6.1/include" -DNDEBUG -I../inst/include/  -I/usr/local/include  -KPIC   -c rcpp_init.cpp -o rcpp_init.o
sh: I/R-3.6.1/R-3.6.1/include: not found

*** Error code 127 (ignored)
-shared -L/usr/local/lib -o Rcpp.so api.o attributes.o barrier.o date.o module.o rcpp_init.o
sh: line 2: -shared: not found
*** Error code 127
The following command caused the error:
if test  "zapi.o attributes.o barrier.o date.o module.o rcpp_init.o" != "z"; then \
  echo  -shared  -L/usr/local/lib -o Rcpp.so api.o attributes.o barrier.o date.o module.o rcpp_init.o   ; \
   -shared  -L/usr/local/lib -o Rcpp.so api.o attributes.o barrier.o date.o module.o rcpp_init.o   ; \
fi
make: Fatal error: Command failed for target `Rcpp.so'
ERROR: compilation failed for package 'Rcpp'
* removing '/R-3.6.1/R-3.6.1/library/Rcpp'

makeconf条目如下:(我们更改了CXX,CXX11,CXX14)

enter code here
# etc/Makeconf.  Generated from Makeconf.in by configure.
#
# ${R_HOME}/etc/Makeconf
#
# R was configured using the following call
# (not including env. vars and site configuration)
# configure 

## This fails if it contains spaces, or if it is quoted
include $(R_SHARE_DIR)/make/vars.mk

AR = ar
BLAS_LIBS = -L"$(R_HOME)/lib$(R_ARCH)" -lRblas
C_VISIBILITY = -fvisibility=hidden
CC = gcc -std=gnu99
CFLAGS = -g -O2 $(LTO)
CPICFLAGS = -fPIC
CPPFLAGS = -I/usr/local/include
CXX = /opt/csw/gcc4/bin
CXXCPP = /lib/cpp
CXXFLAGS =  $(LTO)
CXXPICFLAGS = -KPIC
CXX98 = 
CXX98FLAGS =  $(LTO)
CXX98PICFLAGS = 
CXX98STD = 
CXX11 = /opt/csw/gcc4/bin
CXX11FLAGS =  $(LTO)
CXX11PICFLAGS = 
CXX11STD = 
CXX14 = /opt/csw/gcc4/bin
CXX14FLAGS =  $(LTO)
CXX14PICFLAGS = 
CXX14STD = 
CXX17 = 
CXX17FLAGS =  $(LTO)
CXX17PICFLAGS = 
CXX17STD = 
CXX_VISIBILITY = 
DYLIB_EXT = .so
DYLIB_LD = $(CC)
DYLIB_LDFLAGS = -shared -fopenmp# $(CFLAGS) $(CPICFLAGS)
DYLIB_LINK = $(DYLIB_LD) $(DYLIB_LDFLAGS) $(LDFLAGS)
ECHO = echo
ECHO_C = \c
ECHO_N = 
ECHO_T = 
F_VISIBILITY = -fvisibility=hidden
## FC is the compiler used for all Fortran as from R 3.6.0
FC = gfortran
FCFLAGS = -g -O2 $(LTO)
## additional libs needed when linking with $(FC), e.g. on some Oracle compilers
FCLIBS_XTRA = 
FFLAGS = -g -O2 $(LTO)
FLIBS =  -lgfortran -lm -R/opt/csw/lib
FPICFLAGS = -fPIC
FOUNDATION_CPPFLAGS = 
FOUNDATION_LIBS = 
JAR = 
JAVA = /usr/bin/java
JAVAC = 
JAVAH = 
## JAVA_HOME might be used in the next three.  
## They are for packages 'JavaGD' and 'rJava'
JAVA_HOME = /usr/jdk/instances/jdk1.8.0/jre
JAVA_CPPFLAGS = 
JAVA_LIBS = 
JAVA_LD_LIBRARY_PATH = 
LAPACK_LIBS = -L"$(R_HOME)/lib$(R_ARCH)" -lRlapack
LDFLAGS = -L/usr/local/lib
## we only need this is if it is external, as otherwise link to R
LIBINTL= 
LIBM = -lm
LIBR0 = 
LIBR1 = 
LIBR =  
LIBS =  -lpcre -llzma -lbz2 -lz -lnsl -lsocket -lrt -lsunmath -ldl -lm -liconv -licuuc -licui18n
## needed by R CMD config
LIBnn = lib
LIBTOOL = $(SHELL) "$(R_HOME)/bin/libtool"
LTO = 
## needed to build applications linking to static libR
MAIN_LD = $(CC)
MAIN_LDFLAGS = -fopenmp
MAIN_LINK = $(MAIN_LD) $(MAIN_LDFLAGS) $(LDFLAGS)
MKINSTALLDIRS = "$(R_HOME)/bin/mkinstalldirs"
OBJC = 
OBJCFLAGS =  $(LTO)
OBJC_LIBS = 
OBJCXX = 
R_ARCH = 
RANLIB = ranlib
SAFE_FFLAGS = -g -O2
SED = /usr/xpg4/bin/sed
SHELL = /bin/sh
SHLIB_CFLAGS = 
SHLIB_CXXFLAGS = 
SHLIB_CXXLD = $(CXX)
SHLIB_CXXLDFLAGS = -shared
SHLIB_CXX98LD = $(CXX98) $(CXX98STD)
SHLIB_CXX98LDFLAGS = -shared
SHLIB_CXX11LD = $(CXX11) $(CXX11STD)
SHLIB_CXX11LDFLAGS = -shared
SHLIB_CXX14LD = $(CXX14) $(CXX14STD)
SHLIB_CXX14LDFLAGS = -shared
SHLIB_CXX17LD = $(CXX17) $(CXX17STD)
SHLIB_CXX17LDFLAGS = -shared
SHLIB_EXT = .so
SHLIB_FFLAGS = 
SHLIB_LD = $(CC)
SHLIB_LDFLAGS = -shared# $(CFLAGS) $(CPICFLAGS)
SHLIB_LIBADD = 
## We want to ensure libR is picked up from $(R_HOME)/lib
## before e.g. /usr/local/lib if a version is already installed.
SHLIB_LINK = $(SHLIB_LD) $(SHLIB_LDFLAGS) $(LIBR0) $(LDFLAGS)
SHLIB_OPENMP_CFLAGS = -fopenmp
SHLIB_OPENMP_CXXFLAGS = 
SHLIB_OPENMP_FFLAGS = -fopenmp
STRIP_STATIC_LIB = 
STRIP_SHARED_LIB = 
TCLTK_CPPFLAGS = -I/usr/include
TCLTK_LIBS = 
YACC = yacc

## Legacy settings:  no longer used by R as of 3.6.0
## Setting FC often sets F77 (on Solaris make even if set)
## so must follow FC in this file.
F77 = gfortran
FCPICFLAGS = -fPIC
F77_VISIBILITY = -fvisibility=hidden
SHLIB_FCLD = $(FC)
SHLIB_FCLDFLAGS = -shared
SHLIB_OPENMP_FCFLAGS = -fopenmp


## for linking to libR.a
STATIC_LIBR = #  "$(R_HOME)/lib$(R_ARCH)/libR.a"  $(BLAS_LIBS) $(FLIBS)  $(LIBINTL) -lreadline -lncurses  $(LIBS)

## These are recorded as macros for legacy use in packages
## set on AIX, formerly for old glibc (-D__NO_MATH_INLINES)
R_XTRA_CFLAGS = 
##  was formerly set on HP-UX
R_XTRA_CPPFLAGS =  -I"$(R_INCLUDE_DIR)" -DNDEBUG
## currently unset
R_XTRA_CXXFLAGS = 
## used for gfortran in R > 3.6.0
R_XTRA_FFLAGS = 

## SHLIB_CFLAGS SHLIB_CXXFLAGS SHLIB_FFLAGS are apparently currently unused
## SHLIB_CXXFLAGS is undocumented, there is no SHLIB_FCFLAGS
ALL_CFLAGS =  $(PKG_CFLAGS) $(CPICFLAGS) $(SHLIB_CFLAGS) $(CFLAGS)
ALL_CPPFLAGS =  -I"$(R_INCLUDE_DIR)" -DNDEBUG $(PKG_CPPFLAGS) $(CLINK_CPPFLAGS) $(CPPFLAGS)
ALL_CXXFLAGS =  $(PKG_CXXFLAGS) $(CXXPICFLAGS) $(SHLIB_CXXFLAGS) $(CXXFLAGS)
ALL_OBJCFLAGS = $(PKG_OBJCFLAGS) $(CPICFLAGS) $(SHLIB_CFLAGS) $(OBJCFLAGS)
ALL_OBJCXXFLAGS = $(PKG_OBJCXXFLAGS) $(CXXPICFLAGS) $(SHLIB_CXXFLAGS) $(OBJCXXFLAGS)
ALL_FFLAGS =  $(PKG_FFLAGS) $(FPICFLAGS) $(SHLIB_FFLAGS) $(FFLAGS)
## can be overridden by R CMD SHLIB
P_FCFLAGS = $(PKG_FFLAGS)
ALL_FCFLAGS =  $(P_FCFLAGS) $(FPICFLAGS) $(SHLIB_FFLAGS) $(FCFLAGS)
## LIBR here as a couple of packages use this without SHLIB_LINK
ALL_LIBS = $(PKG_LIBS) $(SHLIB_LIBADD) $(LIBR)# $(LIBINTL)

.SUFFIXES:
.SUFFIXES: .c .cc .cpp .d .f .f90 .f95 .m .mm .M .o

.c.o:
    $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c $< -o $@
.c.d:
    @echo "making $@ from $<"
    @$(CC) -MM $(ALL_CPPFLAGS) $< > $@
.m.d:
    @echo > $@
.cc.o:
    $(CXX) $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) -c $< -o $@
.cpp.o:
    $(CXX) $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) -c $< -o $@
.cc.d:
    @echo > $@
.cpp.d:
    @echo > $@
.m.o:
    $(OBJC) $(ALL_CPPFLAGS) $(ALL_OBJCFLAGS) -c $< -o $@
.mm.o:
    $(OBJCXX) $(ALL_CPPFLAGS) $(ALL_OBJCXXFLAGS) -c $< -o $@
.M.o:
    $(OBJCXX) $(ALL_CPPFLAGS) $(ALL_OBJCXXFLAGS) -c $< -o $@
.f.o:
    $(FC) $(ALL_FFLAGS) -c $< -o $@
## @FCFLAGS_f9x@ are flags needed to recognise the extensions
.f95.o:
    $(FC) $(ALL_FCFLAGS) -c  $< -o $@
.f90.o:
    $(FC) $(ALL_FCFLAGS) -c  $< -o $@

1 个答案:

答案 0 :(得分:0)

让我们看一下已发布的Makeconf文件的某些部分:

CC = gcc -std=gnu99
CFLAGS = -g -O2 $(LTO)
CPICFLAGS = -fPIC
CPPFLAGS = -I/usr/local/include

处理C的这一部分看起来不错。

CXX = /opt/csw/gcc4/bin
CXXCPP = /lib/cpp
CXXFLAGS =  $(LTO)
CXXPICFLAGS = -KPIC

CXX的值必须是C ++编译器的可执行文件,如果不在$PATH中,则可以选择完整路径。例如,我有

CXX = g++ -std=gnu++11

(请注意,C ++ 11是当今的默认设置。)

对于CXXFLAGS,您应该添加优化。一个很好的起点可能是

CXXFLAGS = -g -O2 $(LTO)

最后,CXXPICFLAGS对您的编译器来说是错误的。 -fpic应该可以。

假设所有C ++版本都使用相同的编译器,则CXXnn*变量很简单:

  • CXXnn获取编译器(没有任何其他标志)
  • CXXnnFLAGSCXXnnPICFLAGSCXXFLAGSCXXPICFLAGS
  • CXXnnSTD获取激活该特定标准所需的编译器标志,例如CXX98STD = -std=gnu++98CXX11STD = -std=gnu++11
  • 如果您的编译器不支持标准版本,请保留所有字段为空,例如gcc v4不支持C ++ 17,而C ++ 14可能只是“ C ++ 1y”的一部分