<span style="font-family: Arial; font-size: 13px;"><div>yes I am linking to these gretl libraries but for some reason removed the extern "C", which I shall now bring back!</div><div><br></div>I suspected it was something like that but just wanted to be sure<div><br></div><div>as always, thanks a lot!<br><br>On Friday, December 21, 2012 at 1:15 PM, "Dirk Eddelbuettel" <edd@debian.org> wrote:<blockquote style="border-left:solid 1px #ccc;margin-left:10px;padding-left:10px;">On 21 December 2012 at 12:12, jean.p@hushmail.com wrote:<br>| hi,<br>| <br>| a quick question regarding a Rcpp function I wrote using an external library<br>| (gretl) : <br>| <br>| with the help of a makefile (adapted from the convolution Rcpp example), the<br>| code compiles just fine and turns into a shared object in linux (.so file)<br>| <br>| however, when I then try to load the newly created shared library into R using<br>| dyn.load, I get the following error message:<br>| <br>| <br>| dyn.load("/home/jean/Documents/code experiments/gretl/test2.so")<br>| Error in dyn.load("/home/jean/Documents/code experiments/gretl/test2.so") :<br>|   unable to load shared object '/home/jean/Documents/code experiments/gretl/test2.so':<br>|   /home/jean/Documents/code experiments/gretl/test2.so: undefined symbol: _Z13kalman_smoothP7kalman_PP13gretl_matrix_S3_Pi<br>| <br>| <br>| The undefined symbol is in fact (after c++ unmangling) kalman_smooth(kalman_*,<br>| gretl_matrix_**, gretl_matrix_**, int*), a function from the gretl library<br>| <br>| Do you think the problem comes from the c++ mangling of gretl's  C library or<br>| is it rather linked to internals of gretl ?<br><br>I suspect you are doing something wrong, that is a standard linker error. It<br>could be as easy as forgetting the extern "C" or something.<br><br>The name wrangling happens because it is after all C++ and not C..  Look at<br>the Rcpp + GSL examples for inspiration, or at other CRAN packages working<br>with third-party C libraries.  This works well.<br><br>| many thanks for your help!<br><br>We cannot help much more as you example is not reproducible.<br><br>Dirk<br><br>-- <br>Dirk Eddelbuettel | edd@debian.org | <a href="http://dirk.eddelbuettel.com">http://dirk.eddelbuettel.com</a></blockquote></div></span>