dk. dk. - 1 month ago 4
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:

KG_CPPFLAGS=@cflags@
PKG_LIBS=@libs@


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

gcc -std=gnu99 -shared -L/usr/local/lib64 -o openssl.so [...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

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/Makefile.in.