[Rd] Linking to lapack

Nick Sabbe nick.sabbe at ugent.be
Fri Oct 22 11:30:42 CEST 2010


Hello all.

I'm developing a package for R holding a Gibbs sampler, which tends to have
better performance when written in C than in R.
During each iteration in the Gibbs sampler, I need the inverse of a
symmetric matrix.
For this, I wish to use lapack, as is concisely suggested in "Writing R
extensions", since this will have better performance than I could ever write
myself.

After some twiddling I have got my code to compile by including
"R_ext/Lapack.h" and using "F77_CALL(dpotrf)", but unfortunately, I don't
get this to link properly.
I get this message: " testc.o:testc.c:(.text+0x255): undefined reference to
`dpotrf_'" which seems logical to me as far as my understanding of C
reaches, but I don't know how to resolve it. I'm quite sure I need some
extra parameters in my makefile, but as I come from a world where all these
complexities are happily abstracted away for me by an IDE, I have no actual
clue on how to surmount this.

However: when I'm done with all my code, I wish to build a package for
publication on CRAN, so I want to be sure that not only I can build it on my
system, but it will also work well when distributed to other computers (if I
understand the package process well, source files are compiled and linked
during installation of the package), so I would also like to know how to do
this.

It should not be relevant, but either way: I'm doing all this on a Windows 7
machine, though the package will probably be used on Linux-based servers
eventually.

Finally: I have found no comprehensive list of the functions available to an
R package developer, nor, strangely, questions about that. Does such a thing
exist, or are we up to hoping we find what we are looking for in the header
files? If it does not exist already, I would surely be willing to work on
it.

Thanks for any input.

Nick Sabbe
--
ping: nick.sabbe at ugent.be
link: http://biomath.ugent.be
wink: A1.056, Coupure Links 653, 9000 Gent
ring: 09/264.59.36

-- Do Not Disapprove



More information about the R-devel mailing list