在 Windows 10 上使用 Rtools4.0 构建 R 包
Building R package with Rtools4.0 on Windows 10
我正在尝试使用 RTools4.0 on Windows 10 machine. My package needs the SBML C library and static libraries for SBML for building R packages on Window is provided by RTools4.0
link
构建一个 R
包
我能够成功安装 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
我能够 select 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)
我有点理解为什么会出现错误,因为即使对于 x64
,也使用了 32 位编译器 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
)在我的机器上。
我的问题如下:
在使用 RStudio
的 Clean and Rebuild
选项构建包时,是否可以指定使用 rtools40
?
即使我能够在我的机器上安装这个库,它是否可以用于 CRAN
检查?
如有任何帮助,将不胜感激,谢谢!!
我可以 post 回答我的问题,这有助于解决安装问题。
我必须将 R
中的 PATH
和 BINPREF
设置为:
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 机器上成功安装了软件包。但是,我不确定如何确保为 CRAN
选择了 RTools4.0
。我可以在 Makevars.win
中设置这些首选项吗?
我正在尝试使用 RTools4.0 on Windows 10 machine. My package needs the SBML C library and static libraries for SBML for building R packages on Window is provided by RTools4.0
link
R
包
我能够成功安装 RTools4.0
和附加的 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
我能够 select 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)
我有点理解为什么会出现错误,因为即使对于 x64
,也使用了 32 位编译器 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
)在我的机器上。
我的问题如下:
在使用 RStudio
的 Clean and Rebuild
选项构建包时,是否可以指定使用 rtools40
?
即使我能够在我的机器上安装这个库,它是否可以用于 CRAN
检查?
如有任何帮助,将不胜感激,谢谢!!
我可以 post 回答我的问题,这有助于解决安装问题。
我必须将 R
中的 PATH
和 BINPREF
设置为:
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 机器上成功安装了软件包。但是,我不确定如何确保为 CRAN
选择了 RTools4.0
。我可以在 Makevars.win
中设置这些首选项吗?