<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<div>I'm still having this problem.</div>
<div>I progressively increased the complexity of my code, because my ultimate goal is to integrate a series of C++ classes to perform some functions external to R.</div>
<div><br>
</div>
<div>My test examples worked well, and I just noticed in order to generate the shared object I have to compile together all the classes connected to each others, like this.</div>
<div>PKG_CPPFLAGS=`Rscript -e 'Rcpp:::CxxFlags()'` PKG_LIBS=`Rscript -e 'Rcpp:::LdFlags()'` R CMD SHLIB ClassFive.cpp ClassOne.cpp ClassTwo.cpp ClassThree.cpp ClassFour.cpp</div>
<div><br>
</div>
<div>When I finally compiled my real code, I didn't get any compilation error, but I still got from within R the error message:</div>
<div>
<div>Error in dyn.load("ClassFive.so") : </div>
<div> unable to load shared object [...]</div>
</div>
<div>Symbol not found: __ZN3re23RE23Arg11parse_floatEPKciPv</div>
<div><br>
</div>
<div>I checked for the issues that generated the same problem before, i.e. constructor and deconstructors, and they are all ok.</div>
<div>I couldn't find any explicit call to "parse_float" which seems to be reported in the error message.</div>
<div>To start, I linked only one class to R and one method only of the very same class.</div>
<div><br>
</div>
<div>I understand it might be quite difficult to identify the specific problem without going through lots of code (I have now 5 different classes, each with several methods).</div>
<div>Is there a number of possible mistakes leading to such kind of messages, that could help me narrow down the cause?</div>
<div><br>
</div>
<div>Thanks very much for any help,</div>
<div>Francesco</div>
<div><br>
</div>
<div><br>
</div>
<div>------------</div>
<div>
<div>> sessionInfo()</div>
<div>R version 2.15.1 (2012-06-22)</div>
<div>Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)</div>
<div><br>
</div>
<div>locale:</div>
<div>[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8</div>
<div><br>
</div>
<div>attached base packages:</div>
<div>[1] stats graphics grDevices utils datasets methods base </div>
<div><br>
</div>
<div>other attached packages:</div>
<div>[1] inline_0.3.8 Rcpp_0.9.13 </div>
<div><br>
</div>
<div>loaded via a namespace (and not attached):</div>
<div>[1] tcltk_2.15.1 tools_2.15.1</div>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<br>
<div>
<div>On 6 Jul 2012, at 15:50, Lescai, Francesco wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">
<div>Argh.. Apologies guys.. Found the error myself.<br>
Constructor and deconstructor must be specified with {} even if no code is foreseen for them.<br>
<br>
A novice error, hope at least highlighting it could be useful to other newbies like me :-)<br>
<br>
cheers,<br>
Francesco<br>
<br>
<br>
On 6 Jul 2012, at 15:37, Lescai, Francesco wrote:<br>
<br>
<blockquote type="cite">Hi there,<br>
</blockquote>
<blockquote type="cite">I've seen other posts similar to this one, but I'm a complete novice in the use of Rcpp and couldn't really figure out how to solve the issue.<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">I'm learning how to use Rcpp before connecting R to some C++ classes I'm developing.<br>
</blockquote>
<blockquote type="cite">I started with a simple home made example, but in both cases compiling .cpp and header files or compiling inline code, I get the same outcome error "unable to load shared object" and then "Symbol not found" with some characters before
and after my class name.<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">I've seen Mac OS might have some issues, therefore I tested it also on an Ubuntu virtual machine, but the result is the same error message.<br>
</blockquote>
<blockquote type="cite">Also, I'm using an R-devel version here but I'm having the same problem with R 14 as well.<br>
</blockquote>
<blockquote type="cite">I'll copy below all the relevant information (bit lengthy, I'm sorry).<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">I'd really appreciate some help here to point me in the right direction.<br>
</blockquote>
<blockquote type="cite">thanks very much,<br>
</blockquote>
<blockquote type="cite">Francesco<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">------case 1 - external files -------------------<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">PKG_CPPFLAGS=`Rscript -e 'Rcpp:::CxxFlags()'` PKG_LIBS=`Rscript -e 'Rcpp:::LdFlags()'` R CMD SHLIB example.cpp
<br>
</blockquote>
<blockquote type="cite">g++ -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/x86_64 -DNDEBUG -I/Library/Frameworks/R.framework/Versions/2.16/Resources/library/Rcpp/include -I/usr/local/include
-fPIC -g -O2 -c example.cpp -o example.o<br>
</blockquote>
<blockquote type="cite">g++ -arch x86_64 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -o example.so example.o /Library/Frameworks/R.framework/Versions/2.16/Resources/library/Rcpp/lib/x86_64/libRcpp.a
-F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">
<blockquote type="cite">library(Rcpp)<br>
</blockquote>
</blockquote>
<blockquote type="cite">
<blockquote type="cite">library(inline)<br>
</blockquote>
</blockquote>
<blockquote type="cite">
<blockquote type="cite">dyn.load("example.so")<br>
</blockquote>
</blockquote>
<blockquote type="cite">Error in dyn.load("example.so") : <br>
</blockquote>
<blockquote type="cite">unable to load shared object '/Users/rehbfle/Documents/CPPexercise/RCPP/example.so':<br>
</blockquote>
<blockquote type="cite">dlopen(/Users/rehbfle/Documents/CPPexercise/RCPP/example.so, 6): Symbol not found: __ZN7exampleD1Ev<br>
</blockquote>
<blockquote type="cite">Referenced from: /Users/rehbfle/Documents/CPPexercise/RCPP/example.so<br>
</blockquote>
<blockquote type="cite">Expected in: flat namespace<br>
</blockquote>
<blockquote type="cite">in /Users/rehbfle/Documents/CPPexercise/RCPP/example.so<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">---------case 2 - inline code-----------------------------------------<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">fx<-cxxfunction(signature(), plugin="Rcpp", include=inc) <br>
</blockquote>
<blockquote type="cite">Error in dyn.load(libLFile) : <br>
</blockquote>
<blockquote type="cite">unable to load shared object '/var/folders/qj/p9_mz7r9661gynb8w88sfbvhy6s5_l/T//RtmpaMinm3/file34b510aaf8e3.so':<br>
</blockquote>
<blockquote type="cite">dlopen(/var/folders/qj/p9_mz7r9661gynb8w88sfbvhy6s5_l/T//RtmpaMinm3/file34b510aaf8e3.so, 6): Symbol not found: __ZN7exampleC1Eii<br>
</blockquote>
<blockquote type="cite">Referenced from: /var/folders/qj/p9_mz7r9661gynb8w88sfbvhy6s5_l/T//RtmpaMinm3/file34b510aaf8e3.so<br>
</blockquote>
<blockquote type="cite">Expected in: flat namespace<br>
</blockquote>
<blockquote type="cite">in /var/folders/qj/p9_mz7r9661gynb8w88sfbvhy6s5_l/T//RtmpaMinm3/file34b510aaf8e3.so<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">Below the code details:<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">example.h<br>
</blockquote>
<blockquote type="cite">-------------------------<br>
</blockquote>
<blockquote type="cite">#ifndef EXAMPLE_H<br>
</blockquote>
<blockquote type="cite">#define EXAMPLE_H<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">class example<br>
</blockquote>
<blockquote type="cite">{<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite"><span class="Apple-tab-span" style="white-space:pre"></span>private:<br>
</blockquote>
<blockquote type="cite"><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>float resultone;<br>
</blockquote>
<blockquote type="cite"><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>int resultwo;<br>
</blockquote>
<blockquote type="cite"> public:<br>
</blockquote>
<blockquote type="cite"> example(int x, int y);<br>
</blockquote>
<blockquote type="cite"> ~example();<br>
</blockquote>
<blockquote type="cite"> float multiply(int x, int y);<br>
</blockquote>
<blockquote type="cite"> int doublex(int x);<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">}; <br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">#endif<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">example.cpp<br>
</blockquote>
<blockquote type="cite">---------------------------<br>
</blockquote>
<blockquote type="cite">#include "example.h"<br>
</blockquote>
<blockquote type="cite">#include <Rcpp.h><br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">using namespace Rcpp;<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">example::example(int x, int y){}<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">float example::multiply(int x, int y){<br>
</blockquote>
<blockquote type="cite"> resultone = x * y;<br>
</blockquote>
<blockquote type="cite"> return resultone;<br>
</blockquote>
<blockquote type="cite">}<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">int example::doublex(int x){<br>
</blockquote>
<blockquote type="cite"> resultwo = x * 2;<br>
</blockquote>
<blockquote type="cite"> return resultwo;<br>
</blockquote>
<blockquote type="cite">}<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">RCPP_MODULE(prova){<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite"> <span class="Apple-tab-span" style="white-space:pre">
</span>class_<example>("example")<br>
</blockquote>
<blockquote type="cite"> <span class="Apple-tab-span" style="white-space:pre">
</span>.constructor<int,int>()<br>
</blockquote>
<blockquote type="cite"> <span class="Apple-tab-span" style="white-space:pre">
</span>.method("square", &example::multiply)<br>
</blockquote>
<blockquote type="cite"> <span class="Apple-tab-span" style="white-space:pre">
</span>.method("doppio", &example::doublex)<br>
</blockquote>
<blockquote type="cite"> <span class="Apple-tab-span" style="white-space:pre">
</span>;<br>
</blockquote>
<blockquote type="cite">}<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">----------inline code----------------<br>
</blockquote>
<blockquote type="cite">inc <-'using namespace Rcpp;<br>
</blockquote>
<blockquote type="cite">class example<br>
</blockquote>
<blockquote type="cite">{<br>
</blockquote>
<blockquote type="cite"><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>private:<br>
</blockquote>
<blockquote type="cite"><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>float resultone;<br>
</blockquote>
<blockquote type="cite"><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>int resultwo;<br>
</blockquote>
<blockquote type="cite"><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><br>
</blockquote>
<blockquote type="cite"> public:<br>
</blockquote>
<blockquote type="cite"> example(int x, int y);<br>
</blockquote>
<blockquote type="cite"> ~example();<br>
</blockquote>
<blockquote type="cite"> float multiply(int x, int y){<br>
</blockquote>
<blockquote type="cite"> <span class="Apple-tab-span" style="white-space:pre">
</span>resultone = x * y;<br>
</blockquote>
<blockquote type="cite"> <span class="Apple-tab-span" style="white-space:pre">
</span>return resultone;<br>
</blockquote>
<blockquote type="cite"> }<br>
</blockquote>
<blockquote type="cite"> int doublex(int x){<br>
</blockquote>
<blockquote type="cite"> <span class="Apple-tab-span" style="white-space:pre">
</span>resultwo = x * 2;<br>
</blockquote>
<blockquote type="cite"> <span class="Apple-tab-span" style="white-space:pre">
</span>return resultwo;<br>
</blockquote>
<blockquote type="cite"> }<br>
</blockquote>
<blockquote type="cite"><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><br>
</blockquote>
<blockquote type="cite">}; <br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">RCPP_MODULE(prova){<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite"> <span class="Apple-tab-span" style="white-space:pre">
</span>class_<example>("example")<br>
</blockquote>
<blockquote type="cite"> <span class="Apple-tab-span" style="white-space:pre">
</span>.constructor<int,int>()<br>
</blockquote>
<blockquote type="cite"> <span class="Apple-tab-span" style="white-space:pre">
</span>.method("square", &example::multiply)<br>
</blockquote>
<blockquote type="cite"> <span class="Apple-tab-span" style="white-space:pre">
</span>.method("doppio", &example::doublex)<br>
</blockquote>
<blockquote type="cite"> <span class="Apple-tab-span" style="white-space:pre">
</span>;<br>
</blockquote>
<blockquote type="cite"> }'<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">-----------------<br>
</blockquote>
<blockquote type="cite">
<blockquote type="cite">sessionInfo()<br>
</blockquote>
</blockquote>
<blockquote type="cite">R Under development (unstable) (2012-07-02 r59715)<br>
</blockquote>
<blockquote type="cite">Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">locale:<br>
</blockquote>
<blockquote type="cite">[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">attached base packages:<br>
</blockquote>
<blockquote type="cite">[1] stats graphics grDevices utils datasets methods base <br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">other attached packages:<br>
</blockquote>
<blockquote type="cite">[1] inline_0.3.8 Rcpp_0.9.13 <br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">_______________________________________________<br>
</blockquote>
<blockquote type="cite">Rcpp-devel mailing list<br>
</blockquote>
<blockquote type="cite"><a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-project.org</a><br>
</blockquote>
<blockquote type="cite"><a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a><br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<br>
<br>
<br>
_______________________________________________<br>
Rcpp-devel mailing list<br>
<a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-project.org</a><br>
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel<br>
<br>
</div>
</blockquote>
</div>
<br>
<div apple-content-edited="true">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<div>
<div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; color: rgb(84, 5, 0); font-family: Helvetica; ">
<font size="2" color="blue">---------------------------------------------------------------------------------<br>
</font></div>
</div>
</div>
<div style="font-size: medium; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; color: rgb(84, 5, 0); font-family: Helvetica; ">
<font size="2" color="blue"><b>Francesco Lescai, PhD, EDBT</b><br>
Senior Research Associate in Genome Analysis <br>
University College London</font></div>
<div style="font-size: medium; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; color: rgb(84, 5, 0); font-family: Helvetica; ">
<font size="2" color="blue">Faculty of Population Health Sciences</font></div>
<div style="font-size: medium; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; color: rgb(84, 5, 0); font-family: Helvetica; ">
<font size="2" color="blue">Dept. Genes, Development & Disease</font></div>
<div style="font-size: medium; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; color: rgb(84, 5, 0); font-family: Helvetica; ">
<font size="2" color="blue">ICH - Molecular Medicine Unit, GOSgene team</font></div>
<div style="font-size: medium; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; color: rgb(84, 5, 0); font-family: Helvetica; ">
<font size="2" color="blue">30 Guilford Street</font></div>
<div style="font-size: medium; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; color: rgb(84, 5, 0); font-family: Helvetica; ">
<font size="2" color="blue">WC1N 1EH London UK</font></div>
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<div>
<div style="font-weight: normal; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; color: rgb(84, 5, 0); font-family: Helvetica; ">
<font size="2" color="blue"><br>
email: <a href="mailto:f.lescai@ucl.ac.uk">f.lescai@ucl.ac.uk</a> <br>
phone: +44.(0)207.905.2274 <br>
[ext: 2274] <br>
--------------------------------------------------------------------------------</font></div>
</div>
</div>
</div>
</div>
<br>
</body>
</html>