From simon.urbanek at r-project.org  Sun Feb 19 22:56:44 2012
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Sun, 19 Feb 2012 16:56:44 -0500
Subject: [Rd] include <R.h>
In-Reply-To: <4F415146.6020508@gmail.com>
References: <4F415146.6020508@gmail.com>
Message-ID: <463AE38F-71E6-4DAD-BBF5-E2A411DBD0AE@r-project.org>

Paul,

On Feb 19, 2012, at 2:45 PM, Paul Gilbert wrote:

> I am trying to add
> 
> #include <R.h>
> 
> to a .c file in one of my package, so I can call error() without a complaint about implicit defined function. The src/ has a Makefile, to build some exec/ files that are needed. Without the include, my Makefile target
> 
> OBJS = $(SRC:.c=.o)
> 
> $(PKGNAME).so: $(OBJS) rpcx.h
> 	$(R_HOME)/bin/R CMD SHLIB  $(OBJS)
> 
> seems to work fine, and I do not need a target for the .o's, the default works. But when I add the include, the location of R.h does not get passed along. How am I suppose to specify $(R_HOME)lib/R/include so that it gets passed along by R CMD SHLIB ?
> 

I assume you know that the above general approach won't work very well, so I won't go there... (you don't need Makefile to just add targets).

But your immediate problem is that you want to use R CMD SHLIB $(SRC) and not $(OBJS), otherwise you'll be missing all C*FLAGS (which includes -I that is needed for the headers) since the compilation will be done by your Makefile and not R.

Cheers,
Simon



[Rd] include <R.h>
Simon Urbanek