Looking through the archives I found this thread http://tolstoy.newcastle.edu.au/R/e4/devel/08/02/0347.html and so I tried MAKEFLAGS="CFLAGS=-g -O" R CMD SHLIB ... and this worked great.