4

我正在尝试在 Windows 10 机器上使用RTools4.0R构建一个包。我的包需要 SBML C 库和用于在 Window 上构建 R 包的 SBML 静态库由链接提供RTools4.0

我能够成功安装RTools4.0和附加的 SBML 库。我检查了我是否有 SBML 的头文件

C:\rtools40\mingw64\include\sbml>libsbml.a文件 n

C:\rtools40\mingw64\lib>

更新了最新信息

我的包在 Mac OSX (Mojave) 上成功构建(没有RTools4.0),但是我在 Windows 上安装包时遇到了问题。

我的Makevars.win文件内容如下:

CXX=clang++
PKG_CPPFLAGS= -I/mingw$(WIN)/include/
PKG_LIBS= $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) -lsbml -lbz2 -lz -lxml2 -liconv -lws2_32

我可以rtools40使用以下命令从内部选择和构建包RStudio

Sys.setenv(PATH = paste("C:/rtools40/mingw64/bin", Sys.getenv("PATH"), sep=";"))
Sys.setenv(PATH = paste("C:/rtools40/mingw32/bin", Sys.getenv("PATH"), sep=";"))
Sys.setenv(BINPREF = "C:/rtools40/mingw32/bin/")  
devtools::install()

我得到的错误如下:

Installing Rcppsbml
"C:/PROGRA~1/R/R-34~1.1/bin/x64/R" --no-site-file --no-environ --no-save  \
  --no-restore --quiet CMD INSTALL  \
  "C:/Users/sn248/Documents/GitHub/Rcppsbml"  \
  --library="C:/Users/sn248/Documents/R/win-library/3.4"  \
  --install-tests 

* installing *source* package 'Rcppsbml' ...
** libs

*** arch - i386
C:/rtools40/mingw32/bin/g++  -I"C:/PROGRA~1/R/R-34~1.1/include" -DNDEBUG -I/mingw32/include/ -I"C:/Users/sn248/Documents/R/win-library/3.4/Rcpp/include"   -I"d:/Compiler/gcc-4.9.3/local330/include"     -O2 -Wall  -mtune=core2 -c convertReactions.cpp -o convertReactions.o
C:/rtools40/mingw32/bin/g++  -I"C:/PROGRA~1/R/R-34~1.1/include" -DNDEBUG -I/mingw32/include/ -I"C:/Users/sn248/Documents/R/win-library/3.4/Rcpp/include"   -I"d:/Compiler/gcc-4.9.3/local330/include"     -O2 -Wall  -mtune=core2 -c printSBML.cpp -o printSBML.o
C:/rtools40/mingw32/bin/g++  -I"C:/PROGRA~1/R/R-34~1.1/include" -DNDEBUG -I/mingw32/include/ -I"C:/Users/sn248/Documents/R/win-library/3.4/Rcpp/include"   -I"d:/Compiler/gcc-4.9.3/local330/include"     -O2 -Wall  -mtune=core2 -c rcpp_hello.cpp -o rcpp_hello.o
C:/rtools40/mingw32/bin/g++ -shared -s -static-libgcc -o Rcppsbml.dll tmp.def convertReactions.o printSBML.o rcpp_hello.o -LC:/PROGRA~1/R/R-34~1.1/bin/i386 -lRlapack -LC:/PROGRA~1/R/R-34~1.1/bin/i386 -lRblas -lgfortran -lm -lquadmath -lsbml -lbz2 -lz -lxml2 -liconv -lws2_32 -Ld:/Compiler/gcc-4.9.3/local330/lib/i386 -Ld:/Compiler/gcc-4.9.3/local330/lib -LC:/PROGRA~1/R/R-34~1.1/bin/i386 -lR
installing to C:/Users/sn248/Documents/R/win-library/3.4/Rcppsbml/libs/i386

*** arch - x64
C:/rtools40/mingw32/bin/g++  -I"C:/PROGRA~1/R/R-34~1.1/include" -DNDEBUG -I/mingw64/include/ -I"C:/Users/sn248/Documents/R/win-library/3.4/Rcpp/include"   -I"d:/Compiler/gcc-4.9.3/local330/include"     -O2 -Wall  -mtune=core2 -c convertReactions.cpp -o convertReactions.o
C:/rtools40/mingw32/bin/g++  -I"C:/PROGRA~1/R/R-34~1.1/include" -DNDEBUG -I/mingw64/include/ -I"C:/Users/sn248/Documents/R/win-library/3.4/Rcpp/include"   -I"d:/Compiler/gcc-4.9.3/local330/include"     -O2 -Wall  -mtune=core2 -c printSBML.cpp -o printSBML.o
C:/rtools40/mingw32/bin/g++  -I"C:/PROGRA~1/R/R-34~1.1/include" -DNDEBUG -I/mingw64/include/ -I"C:/Users/sn248/Documents/R/win-library/3.4/Rcpp/include"   -I"d:/Compiler/gcc-4.9.3/local330/include"     -O2 -Wall  -mtune=core2 -c rcpp_hello.cpp -o rcpp_hello.o
C:/rtools40/mingw32/bin/g++ -shared -s -static-libgcc -o Rcppsbml.dll tmp.def convertReactions.o printSBML.o rcpp_hello.o -LC:/PROGRA~1/R/R-34~1.1/bin/x64 -lRlapack -LC:/PROGRA~1/R/R-34~1.1/bin/x64 -lRblas -lgfortran -lm -lquadmath -lsbml -lbz2 -lz -lxml2 -liconv -lws2_32 -Ld:/Compiler/gcc-4.9.3/local330/lib/x64 -Ld:/Compiler/gcc-4.9.3/local330/lib -LC:/PROGRA~1/R/R-34~1.1/bin/x64 -lR
C:/PROGRA~1/R/R-34~1.1/bin/x64/Rlapack.dll: file not recognized: file format not recognized
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'Rcppsbml'
* removing 'C:/Users/sn248/Documents/R/win-library/3.4/Rcppsbml'
* restoring previous 'C:/Users/sn248/Documents/R/win-library/3.4/Rcppsbml'
Error: Command failed (1)

我有点理解为什么我会收到错误,因为即使 for ,也正在使用x6432 位编译器。C:/rtools40/mingw32/bin/g++我不知道如何编写选项来选择正确的编译器,x64因为BINPREF只需要 1 个目录作为输入。

我的R.version信息如下:

> R.version
               _                           
platform       x86_64-w64-mingw32          
arch           x86_64                      
os             mingw32                     
system         x86_64, mingw32             
status                                     
major          3                           
minor          4.1                         
year           2017                        
month          06                          
day            30                          
svn rev        72865                       
language       R                           
version.string R version 3.4.1 (2017-06-30)
nickname       Single Candle 

完整的包代码可以在 - https://github.com/sn248/Rcppsbml

从上面可以看出,我正在使用R-3.4.1(由于非技术问题我现在无法更新)和另一个版本的 Rtools(适用于R-3.4.1)也安装在我的机器上。

我的问题如下:

无论如何在使用'选项rtools40构建包时指定使用?RStudioClean and Rebuild

即使我能够在我的机器上安装这个库,它是否适用于CRAN检查?

非常感谢这里的任何帮助,谢谢!

4

1 回答 1

2

我可以发布一个有助于解决安装问题的问题的答案。

我必须从内部设置PATH为:BINPREFR

Sys.setenv(PATH = paste("C:/rtools40/mingw$(WIN)/bin", Sys.getenv("PATH"), sep=";"))
Sys.setenv(BINPREF = "C:/rtools40/mingw$(WIN)/bin/")  

然后使用安装devtools

devtools::install()

这似乎在我的 Windows 机器上成功安装了包。但是,我不确定如何确保RTools4.0选择CRAN. 我可以在其中设置这些首选项Makevars.win吗?

于 2019-09-08T13:37:03.593 回答