[Rd] Development environment for R extentions on Windows
jeffrey.horner at gmail.com
Fri Sep 10 16:42:47 CEST 2010
On Wed, Sep 8, 2010 at 6:39 PM, Duncan Murdoch <murdoch.duncan at gmail.com> wrote:
> On 08/09/2010 5:37 PM, Jeffrey Horner wrote:
>> On Wed, Sep 8, 2010 at 1:01 PM, Jeffrey Horner <jeffrey.horner at gmail.com>
>>> On Wed, Sep 8, 2010 at 12:37 PM, Duncan Murdoch
>>> <murdoch.duncan at gmail.com> wrote:
>>>> On 08/09/2010 1:21 PM, Jeffrey Horner wrote:
>>>>> Hi all,
>>>>> I'm setting up a development environment on Windows as the subject
>>>>> implies. I've downloaded and installed Rtools211.exe (will upgrade
>>>>> later when necessary) and I've also downloaded and installed mingw
>>>>> with the help of mingw-get.exe.
>>>>> I come from a UNIX development background, so I'm at the bash shell
>>>>> prompt for just about every step in R extenstion development. Question
>>>>> is what is an appropriate environment for Windows development. What
>>>>> shell do you use? Do you use cmd.exe with the PATH variable set up by
>>>>> Rtools? Do you use the sh.exe that comes with Rtools? I've found the
>>>>> bash shell from MinGW to be a pretty close equivalent to bash on UNIX.
>>>>> Do you use something else?
>>>> I've used the bash shell in Cygwin for quite a few years, but I've been
>>>> planning a switch to MSYS sometime. Cygwin seems to have made some bad
>>>> decisions lately that make it harder and harder to work with.
>>> This is great news! I don't know how I could survive without bash's vi
>>> style editing and command completion...
>>> Here's my PATH variable which sets the Rtools paths first, then MinGW:
>>> hornerj at hornerj-win ~
>>> $ echo $PATH
>>> cal/bin:/c/Program Files (x86)/R/R-2.11.1/bin:/c/Program Files
>>> (x86)/CollabNet/Subversion Client:
>>> 0/:/c/Program Files (x86)/MiKTeX 2.8/miktex/bin
>>> I'm going to follow the "R Installation ..." manual to compile R on
>>> Windows and learn a bit about the build process. From there, I intend
>>> to "port" some open source libraries that have support for being
>>> compiled with MS VC++ over to MinGW.
>> From the MinGW bash shell, the R build went quite smoothly. However, I
>> did run into trouble with temporary files. I got around it by
>> specifying TMPDIR like so:
>> $ cd R_HOME/src/gnuwin32
>> $ TMPDIR=. /c/Rtools/bin/make all
> I don't know if anything would go wrong, but I'd avoid putting your temp dir
> into the source tree. On my home machine I normally set R_USER to a
> Windows-style path (with backslashes), and that seems to work. On my work
> machine I think I set TMPDIR explicitly, but I forget what value I used.
>> If I didn't set TMPDIR, it would default to /tmp and the failure would
>> occur within the mkR target of R_HOME/share/make/basepkg.mk. For
>> reasons beyond me, the shell environment that's entered within the mkR
>> target has no notion of a root directory. Anyone else seen this?
> I'm not sure you're using the write make procedure. Are you running make
> from within src/gnuwin32, so you get the Makefile there? It shouldn't try
> to use /tmp (but things might have changed recently).
I was (see above), and I think I've found the culprit.
R_HOME/share/make/basepkg.mk is utilized by both the UNIX and Windows
build, and its target mkR will expand the shell variable f to a
suitable path under /tmp if TMPDIR is not set. Rtools' shell (forked
by make) has no notion of a root file system at /, so /tmp is never
found. The solution is to, of course, always set TMPDIR to a suitable
directory before invoking make. Surprisingly, setting TMPDIR=/tmp
actually works since make expands it to the user's temporary folder.
On my windows laptop, that's:
> Duncan Murdoch
>>> Aside from my PATH variable, are there other things about my
>>> development environment I should be aware of?
More information about the R-devel