dk. dk. - 10 months ago 36
R Question

How do I linking to a non-standard library when building an R package

I'm trying to build the R openssl package and link it to an openssl library that is a newer version than the one in the systemwide lib64 directory.
The Makevars file simply has:


I can specify my local library by passing a custom library path in the
script. But when I issue
, the linking command begins with

gcc -std=gnu99 -shared -L/usr/local/lib64 -o [...objects...] -Lmy/path/here -lssl -lcrypto

As a result, the linker finds the wrong library (the one in /usr/local/lib64) instead of mine.

How do I adjust the linking command so that it looks for the library first in my directory, instead of the system folder.

(Background: I don't have root access and this older version of CentOS (5) doesn't support openssl v1, so I built v1 myself just to compile the R package. But I'm stuck at the linking stage due to whatever magic is happening by R CMD INSTALL.)

dk. dk.
Answer Source

I solved this by passing arguments to R CMD INSTALL. I.e.:

R CMD INSTALL . --configure-vars="INCLUDE_DIR=$HOME/local/include LIB_DIR=$HOME/local/lib64"

But this varies for each package. There's no general solution. Instead, read config and src/