Dear R Community, I adapted the C-Code found at (http://wiki.tcl.tk/25685) implementing fast image resizing for Tk images for my R package. The C Code differs for tcl/tk version 8.4 and 8.5. I have the working code for both versions. How do I integrate this C-Code into my package so that R CMD INSTALL takes care of compiling the function correct for each OS and tcl version? (such that I can submit the package to CRAN). Once the two files would be compiled I could load the correct function by checking with> library(tcltk) > .Tcl('set tcl_version')which tcl version R connects to? For example the gcc command I call under Ubuntu is: gcc -shared -o imgscale.so -DUSE_TCL_STUBS -I/usr/include/tcl8.5/ imagescale_85.c -L/usr/lib/ -ltclstub8.5 -fPIC and gcc -shared -o imgscale.so -DUSE_TCL_STUBS -I/usr/include/tcl8.4/ imagescale_84.c -L/usr/lib/ -ltclstub8.4 -fPIC Thanks, Adrian Waddell
Prof Brian Ripley
2010-Aug-30 07:01 UTC
[Rd] Including C Code for Tcl and Tk in an R package
On Mon, 30 Aug 2010, Adrian Waddell wrote:> Dear R Community, > > I adapted the C-Code found at (http://wiki.tcl.tk/25685) implementing > fast image resizing for Tk images for my R package. > > The C Code differs for tcl/tk version 8.4 and 8.5. I have the working > code for both versions. > > How do I integrate this C-Code into my package so that R CMD INSTALL > takes care of compiling the function correct for each OS and tcl > version? (such that I can submit the package to CRAN). > > Once the two files would be compiled I could load the correct functionYou can't do that: very few systems will have both Tcl 8.4 and 8.5 libraries installed. So you need to use the package's configure script to detect the Tcl/Tk version and also what libraries to compile against. I'm not sure I would try to support Tcl 8.4: 8.5 has been out for a long time now and you could simply make it a package SystemRequirement. We are only support 8.4 in R because we have existing code to do so that has not yet been removed.> by checking with >> library(tcltk) >> .Tcl('set tcl_version') > which tcl version R connects to? > > For example the gcc command I call under Ubuntu is: > > gcc -shared -o imgscale.so -DUSE_TCL_STUBS -I/usr/include/tcl8.5/ > imagescale_85.c -L/usr/lib/ -ltclstub8.5 -fPIC > > and > gcc -shared -o imgscale.so -DUSE_TCL_STUBS -I/usr/include/tcl8.4/ > imagescale_84.c -L/usr/lib/ -ltclstub8.4 -fPIC > > > Thanks, > > Adrian Waddell > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595