
5.5. EXAMPLE: ADJACENCY MATRIX, R-CALLABLE CODE 135
The file y.c must include the R header file:
#include <R.h>
Generally the good thing about compiling via R CMD SHLIB is that we
don’t have to worry where the header file is, or worry about the library
files. But things are a bit more complicated if one’s code uses OpenMP, in
which case we must so inform the compiler. We can do this by setting the
proper environment variable. For C code and the bash shell, for instance,
we would issue the shell command
% e x p o r t SHLIB OPENMP CFLAGS = −fopenmp
Here is a sample run, again in the R interactive shell, with the C file being
AdjMatXformForR.c:
n <− 5
dyn . lo