2017-05-04 49 views
0

我希望将我的R包提交给CRAN,该CRAN使用RcppRcppGSL。我的问题是我无法构建通过R CMD check赢得构建器的包。我的理解是,因为在R CMD check期间构建了i386包,但没有安装和检查。 x64包建立并通过检查(当我运行--no - multiarch检查)。我的理解有点有缺陷,因为我只有有限的时间让这个windows版本在64位工作。 这是Makevars.win.gen由于i386构建无法通过R CMD检查在Windows中由于i386构建

PKG_CPPFLAGS = $(GSL_CFLAGS) -I"$(LIB_GSL)/include" -I"$(LIB_GSL)/include/gsl" -I../inst/include -I../inst -Wall -Wno-unused-but-set-variable -Wno-long-long -Wno-sign-compare -Wno-deprecated -pedantic -pthread -fPIC -O2 -g 
ARCH=x64 
ifeq "$(WIN)" "64" 
ARCH= i386 
else 
ARCH= x64 
endif 
RCPPGSL_LDFLAGS = `$(R_HOME)/bin/$(R_ARCH_BIN)/Rscript -e "RcppGSL:::LdFlags()"` 
GRAPHM_OBJ = ./algorithm_ca.o ./algorithm_ext.o ./algorithm_fsol.o ./algorithm_iden.o ./algorithm_lp.o ./algorithm.o ./algorithm_path.o ./algorithm_qcv.o ./algorithm_rand.o ./algorithm_rank.o ./algorithm_umeyama.o ./algorithm_unif.o ./experiment.o ./graph.o ./hungarian.o ./rpc.o 
GRAPHM_OBJ_REL = $(addprefix ./graphm/,$(GRAPHM_OBJ)) 

PKG_LIBS = $(LDFLAGS) -L"$(LIB_GSL)\lib"$(R_ARCH_BIN) $(RCPPGSL_LDFLAGS) $(GSL_LIBS) -lgsl -lgslcblas 

CXX ?= g++ 
SHVER= 1 
VPATH= ./graphm:./graphm-0.52 


SOURCES= graphmatch_rcpp.cpp RcppExports.cpp 
OBJECTS= $(SOURCES:.cpp=.o) $(GRAPHM_OBJ_REL) 

#all: $(SHLIB) $(OBJECTS) 
$(SHLIB): $(OBJECTS) 
#all: $(ALLFILES) ../inst/libgraphm.a 
# cd graphm && $(MAKE) 
# $(CXX) $(CXXFLAGS) $(OBJECTS) ../inst/libgraphm.a $(PKG_LIBS) 

./experiment.o: experiment.cpp experiment.h 
     cd graphm && $(CXX) $(PKG_CPPFLAGS) -I"$(LIB_GSL)\include" -c experiment.cpp -o ./experiment.o 
./rpc.o: rpc.cpp rpc.h 
     cd graphm && $(CXX) $(PKG_CPPFLAGS) -I"$(LIB_GSL)\include" -c rpc.cpp -o ./rpc.o 
./graph.o: graph.cpp graph.h 
     cd graphm && $(CXX) $(PKG_CPPFLAGS) -I"$(LIB_GSL)\include" -c graph.cpp -o ./graph.o 
./hungarian.o: hungarian.cpp hungarian.h 
     cd graphm && $(CXX) $(PKG_CPPFLAGS) -I"$(LIB_GSL)\include" -c hungarian.cpp -o ./hungarian.o 
./algorithm.o: algorithm.cpp algorithm.h 
     cd graphm && $(CXX) $(PKG_CPPFLAGS) -I"$(LIB_GSL)\include" -c algorithm.cpp -o ./algorithm.o 
#graph matching algorithms 
./algorithm_ca.o: algorithm_ca.cpp algorithm_ca.h 
     cd graphm && $(CXX) $(PKG_CPPFLAGS) -I"$(LIB_GSL)\include" -c algorithm_ca.cpp -o ./algorithm_ca.o 
./algorithm_path.o: algorithm_path.cpp algorithm_path.h 
     cd graphm && $(CXX) $(PKG_CPPFLAGS) -I"$(LIB_GSL)\include" -c algorithm_path.cpp -o ./algorithm_path.o 
./algorithm_ext.o: algorithm_ext.cpp algorithm_ext.h 
     cd graphm && $(CXX) $(PKG_CPPFLAGS) -I"$(LIB_GSL)\include" -c algorithm_ext.cpp -o ./algorithm_ext.o 
./algorithm_fsol.o: algorithm_fsol.cpp algorithm_fsol.h 
     cd graphm && $(CXX) $(PKG_CPPFLAGS) -I"$(LIB_GSL)\include" -c algorithm_fsol.cpp -o ./algorithm_fsol.o 
./algorithm_iden.o: algorithm_iden.cpp algorithm_iden.h 
     cd graphm && $(CXX) $(PKG_CPPFLAGS) -I"$(LIB_GSL)\include" -c algorithm_iden.cpp -o ./algorithm_iden.o 
./algorithm_lp.o: algorithm_lp.cpp algorithm_lp.h 
     cd graphm && $(CXX) $(PKG_CPPFLAGS) -I"$(LIB_GSL)\include" -c algorithm_lp.cpp -o ./algorithm_lp.o 
./algorithm_qcv.o: algorithm_qcv.cpp algorithm_qcv.h 
     cd graphm && $(CXX) $(PKG_CPPFLAGS) -I"$(LIB_GSL)\include" -c algorithm_qcv.cpp -o ./algorithm_qcv.o 
./algorithm_rand.o: algorithm_rand.cpp algorithm_rand.h 
     cd graphm && $(CXX) $(PKG_CPPFLAGS) -I"$(LIB_GSL)\include" -c algorithm_rand.cpp -o ./algorithm_rand.o 
./algorithm_rank.o: algorithm_rank.cpp algorithm_rank.h 
     cd graphm && $(CXX) $(PKG_CPPFLAGS) -I"$(LIB_GSL)\include" -c algorithm_rank.cpp -o ./algorithm_rank.o 
./algorithm_umeyama.o: algorithm_umeyama.cpp algorithm_umeyama.h 
     cd graphm && $(CXX) $(PKG_CPPFLAGS) -I"$(LIB_GSL)\include" -c algorithm_umeyama.cpp -o ./algorithm_umeyama.o 
./algorithm_unif.o: algorithm_unif.cpp algorithm_unif.h 
     cd graphm && $(CXX) $(PKG_CPPFLAGS) -I"$(LIB_GSL)\include" -c algorithm_unif.cpp -o ./algorithm_unif.o 

ALLOBJ: $(OBJECTS) $(GRAPHM_OBJ) 

ALLFILES: $(OBJECTS) $(GRAPHM_OBJ_REL) ../inst/libgraphm.a 



../inst/libgraphm.a: RcppExports.o $(GRAPHM_OBJ) 
    ar -rvs ../inst/libgraphm.a $(GRAPHM_OBJ_REL) 


clean: cleana cleanb 

cleana: 
    rm $(OBJECTS) 
cleanb: 
    rm $(GRAPHM_OBJ_REL) 

#.PHONY: all test clean 

顺便说一句,我用这configure.win到右旗传递给Makevars.win。但是这是不必要的,因为我从Makevars.win.gen中删除了@ GSL_LIBS @。这是在R CMD检查期间没有安装i386 build的原因吗?

ifeq "$(WIN)" "64" 
R_ARCH_BIN="/x64" 
else 
R_ARCH_BIN="/i386" 
endif 
GSL_CFLAGS=`"${R_HOME}/bin$(R_ARCH_BIN)/Rscript.exe" -e "require(RcppGSL);RcppGSL:::CFlags()"` 
GSL_LIBS=`"${R_HOME}/bin$(R_ARCH_BIN)/Rscript.exe" -e "require(RcppGSL);RcppGSL:::LdFlags()"` 
sed -e "s|@[email protected]|${GSL_LIBS}|" \ 
-e "s|@[email protected]|${GSL_CFLAGS}|" \ 
src/Makevars.win.gen > src/Makevars.win 

任何与建立依赖于预先建立的Windows库的多拱R包相关的辅助信息将被赞赏。

回答

1

您的初始假设是错误的,methinks,并且您可能会使这太难。我认为这是值得回踩:

为了本地建立多拱门,你实际上需要本地适当的多拱安装。这意味着GSL的32位和64位版本。

但你不必在本地建立 - 您可以提交您的来源既

  • 双赢的建设者
  • [R枢纽

两者都可以运行一个或几个Windows为您打造!我在每次上传之前使用它们。

另外请注意,你不一定需要Makevars.win所有复杂的。我RcppZiggurat包(CRAN上)只是有这两个指令:

PKG_CPPFLAGS = -I. -I../inst/include 
## Use the R_HOME indirection to support installations of multiple R version 
PKG_LIBS = $(shell "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" \ 
      -e "RcppGSL:::LdFlags()") 

(我加手工换行符)。

最后,RcppGSL有四个反向取决于,所以你有四个工作示例来研究。例如mvabund确实

## This assumes that the LIB_GSL variable points to working GSL libraries 
PKG_CPPFLAGS=-std=c++0x -Wall -pedantic -I$(LIB_GSL)/include -I. -I../inst/include 
PKG_LIBS=-L$(LIB_GSL)/lib -lgsl -lgslcblas 
+0

一些复杂情况是由于封装在包中的C库导致的。我想与C库同时构建包。其余的复杂性是由于我对本地代码和R包构建过程的理解不够,我正在努力解决这个问题。 –

+0

我正要对此发表评论。Makefile看起来是这个部分,但你的问题没有说!但我认为,你们的缺陷几乎完全是由于这一点。试着尽可能地简化它 - 也许只是在src /'中包含所有的库。 –

+0

(我手动添加了换行符)。你是什​​么意思 ? –

0

configure.win在包源树力要建只有主架构的存在,R CMD检查失败与像

<package> is not installed for architecture -- i386 

除非--no-消息多拱是存在的。由于Windows的CRAN构建过程检查两种体系结构(i386和x64),因此即使本地R CMD使用-no-multi-arch检查可能会成功,R CMD检查在CRAN提交过程中失败。

+0

好的。当我需要它时,我在Makevars.win本身中插入了一些依赖于arch的“配置”(这里是file-fetching) - 参见例如[here](https://github.com/Rblp/Rblpapi/blob/master /src/Makevars.win) –