From hin-tak.leung at cimr.cam.ac.uk  Sun Dec 23 23:40:00 2007
From: hin-tak.leung at cimr.cam.ac.uk (Hin-Tak Leung)
Date: Sun, 23 Dec 2007 22:40:00 +0000
Subject: [Rd] Problem with dyn.load'ed code
In-Reply-To: <1198431855.9564.10.camel@calder-linux>
References: <1198431855.9564.10.camel@calder-linux>
Message-ID: <476EE3C0.9080005@cimr.cam.ac.uk>

You are missing some extern "C" declarations? R needs C linkage style.
Basically a lot of:

extern "C" {

}

around your c++ code.


Matt Calder wrote:
> Hi,
>     I am having trouble with some code that I am dyn.loading. I am
> writing an interface to ARPACK. I compile my interface (dssimp.cc), and
> link it against the ARPACK library (libarpack_SUN4.a):
> 
>  g++ -shared -static -fPIC dssimp.cc -o dssimp.so -larpack_SUN4 -lg2c -lm 
> 
> I can dyn.load the code and it appears OK. However, when I call my
> function, the call to the function in the ARPACK library returns an
> error. 
> 	I can print the arguments to my function when I call it from R, so I
> can see that I am dyn.load'd, and the arguments are passed correctly. 	
> 	Moreover, I can load and call the shared object (dssimp.so) using
> dlopen and dlsym from a stand alone C++ program. So I can see that the
> shared object is OK.
> 	In summary, I have a shared object that works correctly outside of R,
> but when dyn.load'd into R, does not work. Short of calling errors
> (which is not the case here) I wonder how that might happen, and how I
> might fix it?
> 
> 	Matt
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] Problem with dyn.load'ed code
Hin-Tak Leung