<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>Thanks, it definitely pointed me in the right direction.</div>
<div>I added the additional flag needed by the compiler </div>
<div>using</div>
<div>PKG_CPPFLAGS=`Rscript -e 'Rcpp:::CxxFlags()'` PKG_LIBS=`Rscript -e 'Rcpp:::LdFlags()'` PKG_LIBS="$PKG_LIBS -lre2" R CMD SHLIB</div>
<div><br>
</div>
<div>and now in dyn.load I have a symbol error demangled as</div>
<div>typeinfo for Rcpp::not_compatible</div>
<div><br>
</div>
<div>I've tested a C++ implementation (partial, the project is not quite complete), and it seems to work.</div>
<div>I had some problems in installing boost regular expression libraries on Mac OSx, so I'm using re2 which doesn't special requirements.</div>
<div>It works in C++, but if that's the problem with linking to R then I have to think to alternative solutions.</div>
<div><br>
</div>
<div>thanks Douglas and Dirk for your help,</div>
<div>Francesco </div>
<div><br>
</div>
<br>
<div>
<div>On 19 Jul 2012, at 02:01, Dirk Eddelbuettel wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">
<div><br>
On 18 July 2012 at 11:47, Douglas Bates wrote:<br>
| One way forward is to use a program like c++filt to demangle the name<br>
| that is not found.  It is<br>
| <br>
| re2::RE2::Arg::parse_float(char const*, int, void*)<br>
<br>
I would also recommend to simplify as much as possible. In such a situation,<br>
I'd try to build a working C++ implementation (without any Rcpp or R) first<br>
to make the design is right.  <br>
<br>
Dirk<br>
<br>
| <br>
| On Wed, Jul 18, 2012 at 11:18 AM, Lescai, Francesco <<a href="mailto:f.lescai@ucl.ac.uk">f.lescai@ucl.ac.uk</a>> wrote:<br>
| > I'm still having this problem.<br>
| > I progressively increased the complexity of my code, because my ultimate<br>
| > goal is to integrate a series of C++ classes to perform some functions<br>
| > external to R.<br>
| ><br>
| > My test examples worked well, and I just noticed in order to generate the<br>
| > shared object I have to compile together all the classes connected to each<br>
| > others, like this.<br>
| > PKG_CPPFLAGS=`Rscript -e 'Rcpp:::CxxFlags()'` PKG_LIBS=`Rscript -e<br>
| > 'Rcpp:::LdFlags()'` R CMD SHLIB ClassFive.cpp ClassOne.cpp ClassTwo.cpp<br>
| > ClassThree.cpp ClassFour.cpp<br>
| ><br>
| > When I finally compiled my real code, I didn't get any compilation error,<br>
| > but I still got from within R the error message:<br>
| > Error in dyn.load("ClassFive.so") :<br>
| >   unable to load shared object [...]<br>
| > Symbol not found: __ZN3re23RE23Arg11parse_floatEPKciPv<br>
| ><br>
| > I checked for the issues that generated the same problem before, i.e.<br>
| > constructor and deconstructors, and they are all ok.<br>
| > I couldn't find any explicit call to "parse_float" which seems to be<br>
| > reported in the error message.<br>
| > To start, I linked only one class to R and one method only of the very same<br>
| > class.<br>
| ><br>
| > I understand it might be quite difficult to identify the specific problem<br>
| > without going through lots of code (I have now 5 different classes, each<br>
| > with several methods).<br>
| > Is there a number of possible mistakes leading to such kind of messages,<br>
| > that could help me narrow down the cause?<br>
| ><br>
| > Thanks very much for any help,<br>
| > Francesco<br>
| ><br>
| ><br>
| > ------------<br>
| >> sessionInfo()<br>
| > R version 2.15.1 (2012-06-22)<br>
| > Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)<br>
| ><br>
| > locale:<br>
| > [1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8<br>
| ><br>
| > attached base packages:<br>
| > [1] stats     graphics  grDevices utils     datasets  methods   base<br>
| ><br>
| > other attached packages:<br>
| > [1] inline_0.3.8 Rcpp_0.9.13<br>
| ><br>
| > loaded via a namespace (and not attached):<br>
| > [1] tcltk_2.15.1 tools_2.15.1<br>
| ><br>
| ><br>
| ><br>
| ><br>
| > On 6 Jul 2012, at 15:50, Lescai, Francesco wrote:<br>
| ><br>
| > Argh.. Apologies guys.. Found the error myself.<br>
| > Constructor and deconstructor must be specified with {} even if no code is<br>
| > foreseen for them.<br>
| ><br>
| > A novice error, hope at least highlighting it could be useful to other<br>
| > newbies like me :-)<br>
| ><br>
| > cheers,<br>
| > Francesco<br>
| ><br>
| ><br>
| > On 6 Jul 2012, at 15:37, Lescai, Francesco wrote:<br>
| ><br>
| > Hi there,<br>
| ><br>
| > I've seen other posts similar to this one, but I'm a complete novice in the<br>
| > use of Rcpp and couldn't really figure out how to solve the issue.<br>
| ><br>
| ><br>
| > I'm learning how to use Rcpp before connecting R to some C++ classes I'm<br>
| > developing.<br>
| ><br>
| > I started with a simple home made example, but in both cases compiling .cpp<br>
| > and header files or compiling inline code, I get the same outcome error<br>
| > "unable to load shared object" and then "Symbol not found" with some<br>
| > characters before and after my class name.<br>
| ><br>
| ><br>
| > I've seen Mac OS might have some issues, therefore I tested it also on an<br>
| > Ubuntu virtual machine, but the result is the same error message.<br>
| ><br>
| > Also, I'm using an R-devel version here but I'm having the same problem with<br>
| > R 14 as well.<br>
| ><br>
| > I'll copy below all the relevant information (bit lengthy, I'm sorry).<br>
| ><br>
| ><br>
| > I'd really appreciate some help here to point me in the right direction.<br>
| ><br>
| > thanks very much,<br>
| ><br>
| > Francesco<br>
| ><br>
| ><br>
| ><br>
| > ------case 1 - external files -------------------<br>
| ><br>
| ><br>
| > PKG_CPPFLAGS=`Rscript -e 'Rcpp:::CxxFlags()'` PKG_LIBS=`Rscript -e<br>
| > 'Rcpp:::LdFlags()'` R CMD SHLIB example.cpp<br>
| ><br>
| > g++ -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include<br>
| > -I/Library/Frameworks/R.framework/Resources/include/x86_64 -DNDEBUG<br>
| > -I/Library/Frameworks/R.framework/Versions/2.16/Resources/library/Rcpp/include<br>
| > -I/usr/local/include    -fPIC  -g -O2  -c example.cpp -o example.o<br>
| ><br>
| > g++ -arch x86_64 -dynamiclib -Wl,-headerpad_max_install_names -undefined<br>
| > dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -o<br>
| > example.so example.o<br>
| > /Library/Frameworks/R.framework/Versions/2.16/Resources/library/Rcpp/lib/x86_64/libRcpp.a<br>
| > -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework<br>
| > -Wl,CoreFoundation<br>
| ><br>
| ><br>
| > library(Rcpp)<br>
| ><br>
| > library(inline)<br>
| ><br>
| > dyn.load("example.so")<br>
| ><br>
| > Error in dyn.load("example.so") :<br>
| ><br>
| > unable to load shared object<br>
| > '/Users/rehbfle/Documents/CPPexercise/RCPP/example.so':<br>
| ><br>
| > dlopen(/Users/rehbfle/Documents/CPPexercise/RCPP/example.so, 6): Symbol not<br>
| > found: __ZN7exampleD1Ev<br>
| ><br>
| > Referenced from: /Users/rehbfle/Documents/CPPexercise/RCPP/example.so<br>
| ><br>
| > Expected in: flat namespace<br>
| ><br>
| > in /Users/rehbfle/Documents/CPPexercise/RCPP/example.so<br>
| ><br>
| ><br>
| ><br>
| > ---------case 2 - inline code-----------------------------------------<br>
| ><br>
| ><br>
| > fx<-cxxfunction(signature(), plugin="Rcpp", include=inc)<br>
| ><br>
| > Error in dyn.load(libLFile) :<br>
| ><br>
| > unable to load shared object<br>
| > '/var/folders/qj/p9_mz7r9661gynb8w88sfbvhy6s5_l/T//RtmpaMinm3/file34b510aaf8e3.so':<br>
| ><br>
| > dlopen(/var/folders/qj/p9_mz7r9661gynb8w88sfbvhy6s5_l/T//RtmpaMinm3/file34b510aaf8e3.so,<br>
| > 6): Symbol not found: __ZN7exampleC1Eii<br>
| ><br>
| > Referenced from:<br>
| > /var/folders/qj/p9_mz7r9661gynb8w88sfbvhy6s5_l/T//RtmpaMinm3/file34b510aaf8e3.so<br>
| ><br>
| > Expected in: flat namespace<br>
| ><br>
| > in<br>
| > /var/folders/qj/p9_mz7r9661gynb8w88sfbvhy6s5_l/T//RtmpaMinm3/file34b510aaf8e3.so<br>
| ><br>
| ><br>
| ><br>
| > Below the code details:<br>
| ><br>
| ><br>
| > example.h<br>
| ><br>
| > -------------------------<br>
| ><br>
| > #ifndef EXAMPLE_H<br>
| ><br>
| > #define EXAMPLE_H<br>
| ><br>
| ><br>
| > class example<br>
| ><br>
| > {<br>
| ><br>
| ><br>
| > private:<br>
| ><br>
| > float resultone;<br>
| ><br>
| > int resultwo;<br>
| ><br>
| >   public:<br>
| ><br>
| >           example(int x, int y);<br>
| ><br>
| >           ~example();<br>
| ><br>
| >           float multiply(int x, int y);<br>
| ><br>
| >           int doublex(int x);<br>
| ><br>
| ><br>
| > };<br>
| ><br>
| ><br>
| ><br>
| > #endif<br>
| ><br>
| ><br>
| ><br>
| > example.cpp<br>
| ><br>
| > ---------------------------<br>
| ><br>
| > #include "example.h"<br>
| ><br>
| > #include <Rcpp.h><br>
| ><br>
| ><br>
| > using namespace Rcpp;<br>
| ><br>
| ><br>
| > example::example(int x, int y){}<br>
| ><br>
| ><br>
| > float example::multiply(int x, int y){<br>
| ><br>
| >       resultone = x * y;<br>
| ><br>
| >       return resultone;<br>
| ><br>
| > }<br>
| ><br>
| ><br>
| > int example::doublex(int x){<br>
| ><br>
| >       resultwo = x * 2;<br>
| ><br>
| >       return resultwo;<br>
| ><br>
| > }<br>
| ><br>
| ><br>
| > RCPP_MODULE(prova){<br>
| ><br>
| ><br>
| >        class_<example>("example")<br>
| ><br>
| >        .constructor<int,int>()<br>
| ><br>
| >        .method("square", &example::multiply)<br>
| ><br>
| >        .method("doppio", &example::doublex)<br>
| ><br>
| >        ;<br>
| ><br>
| > }<br>
| ><br>
| ><br>
| ><br>
| > ----------inline code----------------<br>
| ><br>
| > inc <-'using namespace Rcpp;<br>
| ><br>
| > class example<br>
| ><br>
| > {<br>
| ><br>
| > private:<br>
| ><br>
| > float resultone;<br>
| ><br>
| > int resultwo;<br>
| ><br>
| ><br>
| >       public:<br>
| ><br>
| >               example(int x, int y);<br>
| ><br>
| >               ~example();<br>
| ><br>
| >               float multiply(int x, int y){<br>
| ><br>
| >                resultone = x * y;<br>
| ><br>
| >                return resultone;<br>
| ><br>
| >               }<br>
| ><br>
| >               int doublex(int x){<br>
| ><br>
| >                resultwo = x * 2;<br>
| ><br>
| >                return resultwo;<br>
| ><br>
| >               }<br>
| ><br>
| ><br>
| > };<br>
| ><br>
| ><br>
| > RCPP_MODULE(prova){<br>
| ><br>
| ><br>
| >        class_<example>("example")<br>
| ><br>
| >        .constructor<int,int>()<br>
| ><br>
| >        .method("square", &example::multiply)<br>
| ><br>
| >        .method("doppio", &example::doublex)<br>
| ><br>
| >        ;<br>
| ><br>
| >       }'<br>
| ><br>
| ><br>
| ><br>
| > -----------------<br>
| ><br>
| > sessionInfo()<br>
| ><br>
| > R Under development (unstable) (2012-07-02 r59715)<br>
| ><br>
| > Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)<br>
| ><br>
| ><br>
| > locale:<br>
| ><br>
| > [1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8<br>
| ><br>
| ><br>
| > attached base packages:<br>
| ><br>
| > [1] stats     graphics  grDevices utils     datasets  methods   base<br>
| ><br>
| ><br>
| > other attached packages:<br>
| ><br>
| > [1] inline_0.3.8 Rcpp_0.9.13<br>
| ><br>
| ><br>
| ><br>
| ><br>
| ><br>
| ><br>
| ><br>
| > _______________________________________________<br>
| ><br>
| > Rcpp-devel mailing list<br>
| ><br>
| > <a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-project.org</a><br>
| ><br>
| > <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>
| ><br>
| ><br>
| ><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>
| > <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>
| ><br>
| ><br>
| > ---------------------------------------------------------------------------------<br>
| > Francesco Lescai, PhD, EDBT<br>
| > Senior Research Associate in Genome Analysis<br>
| > University College London<br>
| > Faculty of Population Health Sciences<br>
| > Dept. Genes, Development & Disease<br>
| > ICH - Molecular Medicine Unit, GOSgene team<br>
| > 30 Guilford Street<br>
| > WC1N 1EH London UK<br>
| ><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>
| > --------------------------------------------------------------------------------<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>
| > <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>
| _______________________________________________<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>
| <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>
<br>
-- <br>
Dirk Eddelbuettel | <a href="mailto:edd@debian.org">edd@debian.org</a> | <a href="http://dirk.eddelbuettel.com">
http://dirk.eddelbuettel.com</a>  <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>
<span class="Apple-style-span" style="font-family: Helvetica; ">
<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 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 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 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 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 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 size="2" color="blue">WC1N 1EH London UK</font></div>
</span><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Cambria; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; ">
<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>
</span></div>
</div>
<br>
</body>
</html>