Hi, This question was first posted wrongly on R-help. Apologize for the inconvenience. I am working at a major financial institution and we would like to embed R in one of our front office application. The application is written in C/C++ so I started by trying to compile the examples in "tests/Embedding" of R 2.0.1. I have modified "tests/Embedding/Makefile" according to https://stat.ethz.ch/pipermail/r-help/2005-February/064341.html and set "LD_LIBRARY_PATH" using export LD_LIBRARY_PATH="/home/laurent/R-clean/lib/R/lib" But I get the following error messages during linking: --------------------- laurent@pollux $ make clean laurent@pollux $ make gcc -I. -I../../src/include -I/home/laurent/R-2.0.1/src/include -I/usr/local/include -DHAVE_CONFIG_H -g -O2 -c /home/laurent/R-2.0.1/tests/Embedding/Rtest.c -o Rtest.o gcc -I. -I../../src/include -I/home/laurent/R-2.0.1/src/include -I/usr/local/include -DHAVE_CONFIG_H -g -O2 -c /home/laurent/R-2.0.1/tests/Embedding/embeddedRCall.c -o embeddedRCall.o ../../bin/R CMD LINK gcc -o Rtest Rtest.o embeddedRCall.o -L/home/laurent/R-clean/lib -lR mkdir .libs gcc -o Rtest Rtest.o embeddedRCall.o -L/home/laurent/R-clean/lib -lR -R/home/laurent/R-clean/lib/R/lib Undefined first referenced symbol in file MAIN__ /home/laurent/R-clean/lib/libR.so ld: fatal: Symbol referencing errors. No output written to Rtest collect2: ld returned 1 exit status *** Error code 1 make: Fatal error: Command failed for target `Rtest' ----------------------- I have installed R from source using the following commands. ----------------------- laurent@pollux $ cd /home/laurent/R-clean/ laurent@pollux $ /home/laurent/R-2.0.1/configure --enable-R-shlib --prefix=/home/laurent/R-clean laurent@pollux $ make laurent@pollux $ make install ----------------------- I am running Solaris 5.8 as non-admin user, compiler is gcc 2.95.3. Please let me know if more specific information about the environment is required. Has anyone ne an idea where is the problem? I would be extremly grateful if someone could help us. Best regards, Laurent
Hi, I haven't made any progress regarding compiling the "R embedding" example ( http://tolstoy.newcastle.edu.au/R/devel/05/03/0143.htm ) and I am running out of ideas. I would be very grateful if someone could give me some reference or pointers where to look. In other words, how would you attack the problem if you were in the same situation? Thanks for your help, Laurent
Hi, Thanks for your suggestion. I re-compiled R-2.0.1 with gcc 3.3.2. but got exactly the same problem. I am very puzzled because the compilation of R is ok. Is there any piece of code that was succesfully compiled on my setup that could be used as an example of embedding R in C/C++ (tcltk for example?). Thanks for your help, Laurent $gcc -v Reading specs from /app/gcc_3.3.2/lib/gcc-lib/sparc-sun-solaris2.8/3.3.2/specs Configured with: ../configure --prefix=/app/gcc_3.3.2 --with-local-prefix=/app/gcc_3.3.2 --enable-threads --enable-version-specific-runtime-libs : (reconfigured) ../configure --prefix=/app/gcc_3.3.2 --with-local-prefix=/app/gcc_3.3.2 --enable-threads --enable-version-specific-runtime-libs Thread model: posix gcc version 3.3.2 -----Original Message----- From: Duncan Temple Lang [mailto:duncan@wald.ucdavis.edu] Sent: 21 March 2005 20:01 To: Mauron Laurent (KETR 31) Cc: 'r-devel@stat.math.ethz.ch' Subject: Re: [Rd] Compiling "R Embedded" examples Mauron Laurent (KETR 31) wrote:> Hi, > > I haven't made any progress regarding compiling the "R embedding" example ( http://tolstoy.newcastle.edu.au/R/devel/05/03/0143.htm ) and I am running out of ideas. > > I would be very grateful if someone could give me some reference or pointers where to look. In other words, how would you attack the problem if you were in the same situation?I would install a different version of gcc (e.g. gcc-3.3.3) as that works on one of the Solaris machines I use. SunOS 5.8 Generic_117000-05 sun4u sparc SUNW,Ultra-5_10 On that machine, all works fine.> > Thanks for your help, > > Laurent > > ______________________________________________ > R-devel@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel-- Duncan Temple Lang duncan@wald.ucdavis.edu Department of Statistics work: (530) 752-4782 371 Kerr Hall fax: (530) 752-7099 One Shields Ave. University of California at Davis Davis, CA 95616, USA
Your suggestion to use Rmain.c led to the solution. The compilation of Rmain.c worked ok. I had a look at Rmain.c and found this reference to MAIN__ /* Declarations to keep f77 happy */ int MAIN_(int ac, char **av) {return 0;} int MAIN__(int ac, char **av) {return 0;} int __main(int ac, char **av) {return 0;} Adding those lines to Rtest.c did the trick. I am still puzzled by this problem. The fortran compiler I was using is g77 from gcc3.3.2. $ g77 -v Reading specs from /app/gcc_3.3.2/lib/gcc-lib/sparc-sun-solaris2.8/3.3.2/specs Configured with: ../configure --prefix=/app/gcc_3.3.2 --with-local-prefix=/app/gcc_3.3.2 --enable-threads --enable-version-specific-runtime-libs : (reconfigured) ../configure --prefix=/app/gcc_3.3.2 --with-local-prefix=/app/gcc_3.3.2 --enable-threads --enable-version-specific-runtime-libs Thread model: posix gcc version 3.3.2 Anyway, it works now. Thanks a lot for your help! Laurent -----Original Message----- From: Prof Brian Ripley [mailto:ripley@stats.ox.ac.uk] Sent: 22 March 2005 16:52 To: Mauron Laurent (KETR 31) Cc: 'r-devel@stat.math.ethz.ch' Subject: RE: [Rd] Compiling "R Embedded" examples On Tue, 22 Mar 2005, Mauron Laurent (KETR 31) wrote:> Thanks for your suggestion. I re-compiled R-2.0.1 with gcc 3.3.2. but > got exactly the same problem.(Which problem is not described in this message and the stated URL is invalid. Searching suggests it is related to MAIN__.)> I am very puzzled because the compilation of R is ok. Is there any piece > of code that was succesfully compiled on my setup that could be used as > an example of embedding R in C/C++ (tcltk for example?).No. Only R.bin is in any way similar to the embedded examples: tcltk is run from R, not R from tcltk. Solaris 8, gcc 3.4.3 works for me. Note that MAIN__ is defined in Rmain.c, and that is part of R.bin and not libR.so. You could try copying it is to Rtest.c to see if this helps. What you have not told us is the Fortran that you are using. That is likely to be the clue. Try a current gcc AND g77 -- gcc is a Compiler Collection, not just a C compiler.> $gcc -v > Reading specs from /app/gcc_3.3.2/lib/gcc-lib/sparc-sun-solaris2.8/3.3.2/specs > Configured with: ../configure --prefix=/app/gcc_3.3.2 --with-local-prefix=/app/gcc_3.3.2 --enable-threads --enable-version-specific-runtime-libs : (reconfigured) ../configure --prefix=/app/gcc_3.3.2 --with-local-prefix=/app/gcc_3.3.2 --enable-threads --enable-version-specific-runtime-libs > Thread model: posix > gcc version 3.3.2 > > -----Original Message----- > From: Duncan Temple Lang [mailto:duncan@wald.ucdavis.edu] > Sent: 21 March 2005 20:01 > To: Mauron Laurent (KETR 31) > Cc: 'r-devel@stat.math.ethz.ch' > Subject: Re: [Rd] Compiling "R Embedded" examples > > > Mauron Laurent (KETR 31) wrote: >> Hi, >> >> I haven't made any progress regarding compiling the "R embedding" >> example ( http://tolstoy.newcastle.edu.au/R/devel/05/03/0143.htm ) and >> I am running out of ideas. >> >> I would be very grateful if someone could give me some reference or >> pointers where to look. In other words, how would you attack the >> problem if you were in the same situation? > > > I would install a different version of gcc (e.g. gcc-3.3.3) as that works on > one of the Solaris machines I use. > > SunOS 5.8 Generic_117000-05 sun4u sparc SUNW,Ultra-5_10 > > > On that machine, all works fine.-- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595