【问题标题】:unable to pass R CMD check in windows due to i386 build由于 i386 构建,无法在 Windows 中通过 R CMD 检查
【发布时间】:2017-05-04 18:03:19
【问题描述】:

我希望将我的 R 包提交给使用 Rcpp 和 RcppGSL 的 CRAN。我的问题是我无法在 win-builder 中构建通过 R CMD check 的包。我的理解是,因为i386 包已构建,但在R CMD check 期间未安装和检查。 x64 包构建并通过检查(当我使用 --no--multiarch 运行检查时)。我的理解有点缺陷,因为我没有时间让这个 Windows 构建完全适用于 64 位。 这是Makevars.win.gen

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 构建的原因吗?

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|@GSL_LIBS@|${GSL_LIBS}|" \
-e "s|@GSL_CFLAGS@|${GSL_CFLAGS}|" \
src/Makevars.win.gen > src/Makevars.win

任何与构建依赖于预构建 Windows 库的多架构 R 包相关的辅助信息都将不胜感激。

【问题讨论】:

    标签: r package rcpp cran


    【解决方案1】:

    我认为,您的初始假设是错误的,而且您可能把这弄得太难了。我认为值得退后一步:

    为了本地构建多架构,您实际上需要在本地进行适当的多架构设置。这意味着 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 
    

    【讨论】:

    • 一些复杂性是由于包裹在包周围的 C 库。我想与 C 库同时构建包。其余的复杂性是由于我对本机代码和我试图解决的 R 包构建过程的理解不足。
    • 我正要对此发表评论。 Makefile 看起来很重要,但你的问题没有说!但我认为,你的困难几乎完全是因为这个。尽量简化这一点——也许只是在src/ 中包含所有该库。
    • (我手动添加了换行符)。你这是什么意思?
    • PKG_LIBS 真的是一行。对于帖子,我将其分为两部分。带换行符。手工。
    • 对不起,你的评论让我觉得还有一个我不明白的并发症。
    【解决方案2】:

    包源树中configure.win的存在强制只构建主架构,R CMD检查失败并显示类似消息

     <package> is not installed for architecture -- i386
    

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

    【讨论】:

    • 好收获。当我需要它时,我将一些依赖于架构的“配置”(这里:文件获取)放入 Makevars.win 本身——参见例如here
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-08
    • 1970-01-01
    • 2021-04-18
    • 1970-01-01
    • 1970-01-01
    • 2016-07-24
    相关资源
    最近更新 更多