[Rd] Trying to make DEBUG=T a debug version of R

Duncan Murdoch murdoch.duncan at gmail.com
Thu Apr 11 14:01:36 CEST 2013

On 13-04-10 8:02 PM, Andre Mikulec wrote:
> Hi,
> I am trying to make a debug version of R ( for use with gdb later ) on windows.
> I am executing the following.
> src\gnuwin32>make clean
> src\gnuwin32>make DEBUG=T
> In the output, I see many
> -O3 flags
> I do not see any
>   -g -O0 flags
> which ( I believe/I think ) that is what I need to debug R in gdb.
> What is the proper way to 'make' a 'Debug version of R'?

You don't need -O0 to debug in gdb, you just need the -g flag set 
properly, which DEBUG=T will do for you.  That's how I generally do it.

Setting -O0 might make debugging easier (because it eliminates 
optimizations).  To do that, you'll need to change the CFLAGS setting in 
src/gnuwin32/Makefiles.  (You may also be able to do it with a CFLAGS 
environment variable, I haven't tried.)  I don't usually do this, since 
it changes the code:  if you need gdb, chances are the bug is subtle, 
and its behaviour may change with optimization level.  But you may have 
a different preference.

Duncan Murdoch

More information about the R-devel mailing list