Skip to content
Back to formatted view

Raw Message

Message-ID: <383F55BD-E1C6-4D0C-99A9-FB5E53EC46B8@stat.ubc.ca>
Date: 2011-06-27T16:04:14Z
From: Davor Cubranic
Subject: [Rcpp-devel] Templates failing to specialize
In-Reply-To: <BAFC0A90-C273-4844-A17D-A4DD1AE0B65B@stat.ucla.edu>

See the C++ FAQ: http://www.parashift.com/c++-faq-lite/templates.html#faq-35.13

Davor


On 2011-06-27, at 8:49 AM, Ian Fellows wrote:

> Hi,
> 
> I have am having trouble using template classes in rcpp. The compiling process works just fine, but there are errors on link. It seems as if the methods are not getting specialized.
> 
> The Error:
> ** testing if installed package can be loaded
> Error in dyn.load(file, DLLpath = DLLpath, ...) : 
>   unable to load shared object '/Library/Frameworks/R.framework/Versions/2.13/Resources/library/gergm/libs/x86_64/gergm.so':
>   dlopen(/Library/Frameworks/R.framework/Versions/2.13/Resources/library/gergm/libs/x86_64/gergm.so, 6): Symbol not found: __ZN5gergm9BinaryNetINS_14DirectedVertexEE4sizeEv
>   Referenced from: /Library/Frameworks/R.framework/Versions/2.13/Resources/library/gergm/libs/x86_64/gergm.so
>   Expected in: flat namespace
>  in /Library/Frameworks/R.framework/Versions/2.13/Resources/library/gergm/libs/x86_64/gergm.so
> Error: loading failed
> Execution halted
> ERROR: loading failed
> 
> 
> The basic form of the class is:
> 
> template<class T>
> class BinaryNet{
> public:
> 	int size();
> };
> 
> template<class T>
> void BinaryNet<T>::size(){return 1;}
> 
> BinaryNet is called in a function in a separate c++ file. If I explicitly add the specialization, then everything works out fine
> 
> template<>
> void BinaryNet<DirectedVertex>::size(){return 1;}
> 
> How can I make sure that these specializations are created. I apologize if this is more a c++ question than an Rcpp one.
> 
> 
> Best,
> Ian
> 
> 
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20110627/2733edc4/attachment.htm>