[R] Building 'R' from source for Windows.

Duncan Murdoch murdoch at stats.uwo.ca
Sun Aug 16 02:01:57 CEST 2009


rkevinburton at charter.net wrote:
> Thank you for looking into this. It turns out the problem was "You are misinterpreting R_HOME.  . . " I thought R_HOME was were I installed R not the directory where I was trying to compile the source. Once I moved the "extra" stuff that RTools.exe installed in what I thought was the R installation directory to where I was trying to cimpile the R source it became apparent what I had done wrong. Thanks again.
>
> But unfortunately this brings up two more questions. One the function or project that I would like to start debugging is in appl (I would like to step into the L-LBFGSB lbfgsb.c code). The documentation that was with the RTools code mentioned that if I built a package like 'make DEBUG=T package' it would insert -gdwarf-2 in the compiler swtiches and that would allow be to set a breakpoint. Well I am not sure if the fact that this is not a package if that is why it didn't work but if I go to the appl directory and enter 'make DEBUG=T', I don't see gcc called with -gdwarf-2. If I go to the gnuwin32 directory and try to build all of 'R' like 'make DEBUG=T all recommended' I see the -gdwarf=2 flag added to compilation of each file. But I would rather not add debugging information to all the source in R. Any suggestions?
>   

Build R without debugging, touch the files you want to debug, and 
rebuild it.  But "make DEBUG=T package" will never work:  package is 
unlikely to be a make target.  You need Rcmd INSTALL package, with 
DEBUG=T defined in the environment.
> The second question is kind of like 'Where do I go from here?'. From the instructions I get that I probably need to use 'Inno' to build an installation. Hopefully once the first problem is solved this installation will have debugging symbols where I need them. If I run the resultant self-extracting installer will that just overwrite my R installation and now I debug with that?
>   

Don't bother installing.  Just debug what gets built in the bin directory.
> Again, thanks for the additional tips. It has been a long time since I last debugged with anything other than Windows Visual Studio and this will take some getting used to.
>   

Debugging gcc programs in Windows is rather painful.  The problems are:

  - MinGW doesn't provide a graphical front end.  You need to go back to 
the 70s and debug using gdb.

  - Cygwin does provide Insight, but it's like living in the early 90s, 
and it doesn't completely work.

  - We (blame me!) don't provide an easy way to build R with different 
optimization levels than the one we use for distribution builds.  
Building with -O0 might make debugging easier, if it doesn't change the 
meaning of the program.  (If it does change the meaning, it will waste 
so much time that I've decided not to do it.)

   - Microsoft and other makers of good debuggers won't support gcc 
debug info.  It would take one of their programmers a couple of weeks to 
do so, but they choose not to.

One more comment below...
> Kevin
>
> ---- Peter Dalgaard <p.dalgaard at biostat.ku.dk> wrote: 
>   
>> rkevinburton at charter.net wrote:
>>     
>>> I know I am going to catch alot of comments for this question but I am really stuck. If there is some written documentation that I have missed please redirect me.
>>>
>>> I want to build 'R' from source on a Windows Platform. The main reasons are that I want to check out a debugging some existing packages so I need to build with debug symbols and I want to check out a 64-bit version of 'R'. So I read the instuructions and downloaded and installed 'rtools' and extracted the source. Then I ran into this statement in R-admin.pdf:
>>>
>>>       
>>>> Open a command window at ‘R_HOME/src/gnuwin32’. Edit ‘MkRules’ to set the >appropriate paths as needed and to set the type(s) of help that you want built. >Beware: ‘MkRules’ contains tabs and some editors (e.g., WinEdt) silently remove >them. Then run make all recommended and sit back and wait while the basic >compile takes place.
>>>>         
>>> But when I go to this directory I don't see MkRules. In fact I don't see any files, just folders (bitmap and unicode). Are the instructions wrong ? Have I missed a step? Or is there somewhere I can retrieve the missing file (MkRules)?
>>>
>>> Thank you. 
>>>
>>> Kevin
>>>       
>> It should be there. Three possibilities:
>>
>> - Your editor is not showing it because of extension issues (look for 
>> "All files")
>>
>> - You are misinterpreting R_HOME as something other than the source 
>> directory. (Could this be a typo? R_HOME is usually the destination dir, 
>> but source is what makes sense here. Or are the instructions assuming 
>> builddir=srcdir=destdir?)
>>     

On Windows, builddir=srcdir=destdir. 

Duncan Murdoch
>> - You unpacked it incorrectly or got the wrong source file. I checked 
>> http://cran.r-project.org/src/base/R-2/R-2.9.1.tar.gz and it does have 
>> the file in the right place.
>>
>>
>> -- 
>>     O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
>>    c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
>>   (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
>> ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907
>>     
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>




More information about the R-help mailing list