R-beta: linking c++ functions

Kung-Sik Chan (kchan@stat.uiowa.edu)
Sun, 14 Sep 1997 17:01:29 -0700


Date: Sun, 14 Sep 1997 17:01:29 -0700
From: Kung-Sik Chan <kchan@stat.uiowa.edu>
To: r-help@stat.math.ethz.ch
Subject: R-beta: linking c++ functions

I have written some C++ functions and want to port the functions into
an R library, but got the following error message when I invoked the
library called chaos:

> library(chaos)
/usr/local/lib/R/bin/R.binary: can't resolve symbol 'cout'
/usr/local/lib/R/bin/R.binary: can't resolve symbol '__ls__7ostreamPCc'
/usr/local/lib/R/bin/R.binary: can't resolve symbol 'cout'
/usr/local/lib/R/bin/R.binary: can't resolve symbol '__ls__7ostreamPCc'
/usr/local/lib/R/bin/R.binary: can't resolve symbol '__ls__7ostreamPCc'
/usr/local/lib/R/bin/R.binary: can't resolve symbol '__ls__7ostreamPCc'
/usr/local/lib/R/bin/R.binary: can't resolve symbol 'cout'
/usr/local/lib/R/bin/R.binary: can't resolve symbol '__ls__7ostreamPCc'
/usr/local/lib/R/bin/R.binary: can't resolve symbol 'cout'
/usr/local/lib/R/bin/R.binary: can't resolve symbol '__ls__7ostreamPCc'
/usr/local/lib/R/bin/R.binary: can't resolve symbol '__ls__7ostreamPCc'
Error in dyn.load(system.file("lib", name)) : unable to load shared library "/us
r/local/lib/R/lib/chaos.so"  

In fact, I used in my C++ functions the newmat library which is a library
of matrix classes. The following is the makefile in my sub-dirctory
RHOME/src/library/chaos/src, which seems to compile ok resulting in 
the  chaos.so file.


..cc.o:
        g++ -c $(CFLAGS) -I/usr/include/newmat -I/usr/include/nric -lnewmat -lm $<
LIBNAME=chaos
LD=ld

OBJS=   lyapunov.o

chaos.so:       $(OBJS)
        $(LD) $(SHLIBLDFLAGS) -o $(LIBNAME).so $(OBJS)  \
        -lnewmat -lm

clean:
        @rm -f *.o *.so

realclean:
        @rm -f Makefile *.o *.so  

I'll appreciate suggestions on how to fix the problem. Thanks.

Kung-Sik Chan
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=