I am trying to build an R
package using 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
I was able to successfully install RTools4.0
and the additional SBML library. I checked that I have the header files for SBML in
C:\rtools40\mingw64\include\sbml>
and the libsbml.a
file n
C:\rtools40\mingw64\lib>
Updated with latest information
My package builds successfully on Mac OSX (Mojave) (without RTools4.0
), however I am facing issues with installing my package on Windows.
The contents of my Makevars.win
file are as follows:
CXX=clang++
PKG_CPPFLAGS= -I/mingw$(WIN)/include/
PKG_LIBS= $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) -lsbml -lbz2 -lz -lxml2 -liconv -lws2_32
I am able to select rtools40
and build the package using the following commands from within 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()
And the error I am getting is given below:
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)
I sort of understand why I am getting the error because even for x64
, the 32-bit compiler C:/rtools40/mingw32/bin/g++
is being used. I don't know how to write the options to choose the correct compiler for x64
since BINPREF
only takes 1 directory as an input.
My R.version
information is given below:
> 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
The entire package code can be found at - https://github.com/sn248/Rcppsbml
As seen from above, I am using R-3.4.1
(which I can't update for now due to non-technical issues) and another version of Rtools (appropriate for R-3.4.1
) also installed on my machine.
My questions are as follows:
Is there anyway to specify using rtools40
while building the package using RStudio
's Clean and Rebuild
option?
Even if I am able to install this library on my machine, will it work for CRAN
checks?
Any help here would be very much appreciated, thanks!!
I can post an answer to my problem that helped solved the installation problem.
I had to set PATH
and BINPREF
from within R
as:
Sys.setenv(PATH = paste("C:/rtools40/mingw$(WIN)/bin", Sys.getenv("PATH"), sep=";"))
Sys.setenv(BINPREF = "C:/rtools40/mingw$(WIN)/bin/")
then installation using devtools
devtools::install()
This seems to install the package successfully on my Windows machine. However, I am not sure how do I make sure RTools4.0
is selected for CRAN
. Can I set these preferences in Makevars.win
?