【发布时间】:2016-10-06 23:00:00
【问题描述】:
我正在尝试构建一个 R 包,它是 Windows 中 C 库(并且使用 gsl)的包装器。如有必要,我可以过渡到 Linux 无论好坏,我将 C 库的 make 命令放在 Makevars.in 中。 我使用 Rstudio 的 Rcpp 骨架功能来创建包。我已经安装了 Rtools 3.3 并使用了 R 3.3.1
并且我将 Rcpp 和 RcppGSL 包含在 DESCRIPTION 的 LinkingTo 字段中。我仍然收到 make 命令的未定义参考错误
$(CXX) $(CXXFLAGS) $(OBJECTS) ../inst/libgraphm.a $(PKG_LIBS)
一些错误如下
c:/Rtools/mingw_64/bin/g++ -shared -s -static-libgcc -o RGraphM.dll tmp.def graphmatch_rcpp.o RcppExports.o -L../inst -lgraphm -LC:/tools/gsl/lib/x64 -lgsl -lgslcblas -Ld:/Compiler/gcc-4.9.3/local330/lib/x64 -Ld:/Compiler/gcc-4.9.3/local330/lib -LC:/PROGRA~1/R/R-33~1.1/bin/x64 -lR
#cd graphm && /usr/bin/make
c:/Rtools/mingw_64/bin/g++ -O2 -Wall -mtune=core2 graphmatch_rcpp.o RcppExports.o ../inst/libgraphm.a -L../inst -lgraphm -LC:/tools/gsl/lib/x64 -lgsl -lgslcblas
graphmatch_rcpp.o: In function `PreserveStorage':
C:/Users/sadali/Documents/R/win-library/3.3/Rcpp/include/Rcpp/storage/PreserveStorage.h:10: undefined reference to `__imp_R_NilValue'
graphmatch_rcpp.o: In function `Vector':
C:/Users/sadali/Documents/R/win-library/3.3/Rcpp/include/Rcpp/vector/Vector.h:58: undefined reference to `Rf_allocVector'
graphmatch_rcpp.o: In function `Rcpp_ReplaceObject':
这个类似(在我看来)问题的答案似乎不适用 Undefined reference errors when including Rcpp.h 因为我正在使用 LinkingTo 并尝试创建一个 R 包
编辑:正如第一个答案所建议的那样,我尝试使用以下 Makevars.win 构建 RcppZiggurat:
PKG_CPPFLAGS = -I. -I../inst/include -IC:/tools/gsl/include
## Use the R_HOME indirection to support installations of multiple R version
PKG_LIBS = $(LDFLAGS) -L../inst -L$(LIB_GSL)/lib/x64 $(shell "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" -e "RcppGSL:::LdFlags()")
我收到这些错误。
ziggurat.o:ziggurat.cpp:(.text+0x86): undefined reference to `gsl_rng_free'
ziggurat.o:ziggurat.cpp:(.text+0xa6): undefined reference to `gsl_rng_free'
ziggurat.o:ziggurat.cpp:(.text+0xc6): undefined reference to `gsl_rng_free'
ziggurat.o:ziggurat.cpp:(.text+0x1254): undefined reference to `gsl_rng_set'
【问题讨论】:
-
graphmatch_rcpp.cpp的第一个显着行会很有用,但 this 可能是您的问题