[Rcpp-devel] Templates failing to specialize

Ian Fellows ian.fellows at stat.ucla.edu
Mon Jun 27 17:49:01 CEST 2011


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


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


More information about the Rcpp-devel mailing list