[R] Makefile to compile .so in src (was: Re: automated libR location)

Matyas Sustik msustik at gmail.com
Wed Feb 1 03:37:09 CET 2012

Prof Brian Ripley wrote:
> 'library' in R has a different meaning: I've altered the subject to be
> more accurate 'libR'.
> This is what R CMD SHLIB is for: it does all this for you in a portable way.
> But if you want to DIY, you can use R CMD config to find out the
> appropriate linker incantation.

Thank you for the clarification.  I do not insist on doing it myself
and would welcome
R doing it automatically.  I guess I did not fully understand the
instructions in the
document "R Extensions".  (English is my second language.)

A small example compiling a single .so would help greatly I think.  My
current Makefile
that I put in src of  a package skeleton looks like this to create the
.so on Linux:

all :  QUIC.so



QUIC.o : QUIC.cpp
       g++ -O3 -DNDEBUG -Wall -fpic -pthread -shared
-fno-omit-frame-pointer -ansi -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -c
QUIC.cpp -o QUIC.o

QUIC.so : QUIC.o
	g++ -std=gnu99  -shared -lm -llapack -lblas -L/usr/lib/R/lib -lR -O3
QUIC.o -o QUIC.so

This actually built and created a loadable package but I would want to
do it more the R-way.

Thanks in advance!

More information about the R-help mailing list