[Rcpp-devel] Rcpp and C++ mangling

jean.p at hushmail.com jean.p at hushmail.com
Fri Dec 21 13:26:34 CET 2012


yes I am linking to these gretl libraries but for some reason removed
the extern "C", which I shall now bring back!
I suspected it was something like that but just wanted to be sure
as always, thanks a lot!

On Friday, December 21, 2012 at 1:15 PM, "Dirk Eddelbuettel"  wrote:On
21 December 2012 at 12:12, jean.p at hushmail.com wrote:
| hi,
| 
| a quick question regarding a Rcpp function I wrote using an external
library
| (gretl) : 
| 
| with the help of a makefile (adapted from the convolution Rcpp
example), the
| code compiles just fine and turns into a shared object in linux (.so
file)
| 
| however, when I then try to load the newly created shared library
into R using
| dyn.load, I get the following error message:
| 
| 
| dyn.load("/home/jean/Documents/code experiments/gretl/test2.so")
| Error in dyn.load("/home/jean/Documents/code
experiments/gretl/test2.so") :
|   unable to load shared object '/home/jean/Documents/code
experiments/gretl/test2.so':
|   /home/jean/Documents/code experiments/gretl/test2.so: undefined
symbol: _Z13kalman_smoothP7kalman_PP13gretl_matrix_S3_Pi
| 
| 
| The undefined symbol is in fact (after c++ unmangling)
kalman_smooth(kalman_*,
| gretl_matrix_**, gretl_matrix_**, int*), a function from the gretl
library
| 
| Do you think the problem comes from the c++ mangling of gretl's  C
library or
| is it rather linked to internals of gretl ?

I suspect you are doing something wrong, that is a standard linker
error. It
could be as easy as forgetting the extern "C" or something.

The name wrangling happens because it is after all C++ and not C.. 
Look at
the Rcpp + GSL examples for inspiration, or at other CRAN packages
working
with third-party C libraries.  This works well.

| many thanks for your help!

We cannot help much more as you example is not reproducible.

Dirk

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20121221/ed092874/attachment.html>


More information about the Rcpp-devel mailing list