From ml_a at waddell.ch  Mon Aug 30 08:01:18 2010
From: ml_a at waddell.ch (Adrian Waddell)
Date: Mon, 30 Aug 2010 02:01:18 -0400
Subject: [Rd] Including C Code for Tcl and Tk in an R package
Message-ID: <4C7B492E.2060200@waddell.ch>

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



[Rd] Including C Code for Tcl and Tk in an R package
Adrian Waddell