[Rd] problem in linking to libR.so with R 2.5.0

From: Jiangtian Li <jli3_at_ncsu.edu>
Date: Wed, 7 Nov 2007 00:46:01 -0500 (EST)

Dear All,

I tried to write a C++ program that uses R internals and I encounter "undefined reference" error when linking to libR.so. Here is an small example of the program test.cpp:

extern "C" {
#include <config.h>
#include <IOStuff.h>

int main(int argc, char** argv)
  return 0;


I built it using:
g++ -o test -I/dir/to/R-2.5.0/src/include -L/dir/to/R-2.5.0/lib/R/lib -lR test.cpp

and I got the error message:

/tmp/cc4zxrqh.o(.text+0x20): In function `main': test.cpp: undefined reference to `R_ConsoleIob' /tmp/cc4zxrqh.o(.text+0x25):test.cpp: undefined reference to `R_IoBufferInit' collect2: ld returned 1 exit status

I installed R 2.5.0 on Fedora Core 4 with gcc 4.0.2 and configured with --prefix=/dir/to/R-2.5.0 --enable-R-shlib

I did that with R 2.2.1 and can build without problem. Any suggestion on how to link to libR.so in later R versions? Your help is very appreciated.

Best regards,

R-devel_at_r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed 07 Nov 2007 - 05:50:19 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 07 Nov 2007 - 07:30:15 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.