Reputation: 1800
I am building a package with provides a wrapper around the cvode solver from the SUNDIALS ODE solving C library.
So far, I have been able to compile the package on my OS X
machine by providing the source C files (taking inspiration from the Makevars
from RcppCAF package) and making the static library on the fly and linking against it. The Makevars
file can be found at the link below
https://github.com/sn248/Rcppsbmod/blob/master/src/Makevars
Earlier I was linking against static libraries on the system but now since I am making the static library (libsundials_all.a
) on the fly when compiling the package, I believe users who don't have SUNDIALS installed on their system (at least on OS X
) should be able to use this package also (Am I correct in thinking this?). I have checked the package compiled in such a way is able to integrate the a test ODE. Also, When I run a R CMD check
(using Check
option on RStudio, with --as-cran
option), I get success, i.e.,
R CMD check results
0 errors | 0 warnings | 0 notes
However, I want users on Windows to be able to use this package, even if they don't have SUNDIALS installed on their machine, my questions are
Currently my Makevars.win
is same as Makevars
, so when I submit my package on R WinBuilder, I get the following message (which tells me that make
is not able to find ar
).
make: ar: Command not found
make: *** [../inst/libsundials_all.a] Error 127
Warning: running command 'make -f "Makevars.win" -f "D:/RCompile/recent/R-3.4.3/etc/i386/Makeconf" -f "D:/RCompile/recent/R-3.4.3/etc/i386/Makevars.site" -f "D:/RCompile/recent/R-3.4.3/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="Rcppsbmod.dll" ' had status 2
ERROR: compilation failed for package 'Rcppsbmod'
* removing 'd:/RCompile/CRANguest/R-release/lib/Rcppsbmod'
In R CMD INSTALL
Some searching revealed that RTools
might not have ar
,here but I don't think I am clear about what I should be doing to compile this package on Windows. I have looked a few Makevars.win
files, but most of them are similar to Makevars
. I feel I need to make a .dll
(similar to libsundials_all.a
, but I am not sure how to go about it at all.
Any suggestion here about how I can compile this package on Windows will be much appreciated!
Also, just for my curiosity, I often find code such (e.g., in Makevars.in
of rcppgsl
)
GSL_LIBS = @GSL_LIBS@
I am not sure what @GSL_LIBS@
means and make
tutorials didn't have this syntax either. Any explanation of this code will be very helpful.
Thanks!
Upvotes: 1
Views: 439
Reputation: 26823
Yes, it is possible to build a static library on Windows during package installation. I am doing that in the experimental windows branch of dqmagic:
PKG_CPPFLAGS = -I./libmagic -I./libgnurx -DHAVE_CONFIG_H
PKG_LIBS = -L. -lmagic -lregex -lshlwapi
all: $(SHLIB)
$(SHLIB): libmagic.a libregex.a
LIBMAGIC =libmagic/apprentice.o \
[... many object files ...]
libmagic.a: $(LIBMAGIC)
LIBREGEX = libgnurx/regex.o
libregex.a: $(LIBREGEX)
Note that I do not tell make
how to build a static library, leaving that to the automatic rules. That way there are no issues with ar
missing. Note that the Linux/Mac OSX build uses a system installed library.
I think RcppGSL is not a good comparison in your case, since it uses an external library on all platforms. Reason is that with this package it has to be possible to compile and link with GSL after package installation. In your case, all the compilation and linking is done at installation time, right?
Upvotes: 1