[Rcpp-devel] error: wrap is not a template function

Qiang Kou qkou at umail.iu.edu
Thu May 21 21:49:55 CEST 2015


Hi, Fabio,

I think it will be better if you can open a repo on github and upload your
package.

Besides, I can give you a simple example I wrote before [1].

Best wishes,

KK

[1] https://github.com/thirdwing/RcppDL/blob/master/src/util.h



On Thu, May 21, 2015 at 11:17 AM, Fabio Tordini <tordini at di.unito.it> wrote:

> Hello,
>
> while extending Rcpp with my C++ classes, I received hundreds of " 'wrap'
> is not a template function" and " 'as' is not a template function" errors
> when compiling. Beside this, I get an impressive list of errors referring
> to RcppGSL files.
>
> The library from which my classes come from makes use GSL (on C++ side),
> thus I link RcppGSL to my package.
>
> Here is my extending for one class:
> #ifndef SAMDATA_HPP_
> #define SAMDATA_HPP_
>
> class SamData;
>
> #include <RcppCommon.h>
>
> namespace Rcpp {
>     template<> SEXP wrap(const SamData &s);
>     template<> SamData as( SEXP s ) ;
> }
>
> #include <Rcpp.h>
>
> #include "common.hpp"
>
> class SamData {
>
>     // class implementation
> };
>
> namespace Rcpp {
>
> template<> SEXP wrap(const SamData &s) {
>    return Rcpp::List::create( Rcpp::Named("Chr1") = s.getChr1(),
>                               Rcpp::Named("Chr2") = s.getChr2(),
>                               Rcpp::Named("Seq1") = s.getSeq(),
>                               Rcpp::Named("HS1")  = s.getHS1(),
>                               Rcpp::Named("HS2")  = s.getHS2(),
>                               Rcpp::Named("Id")   = s.getId(),
>                               Rcpp::Named("Start1") = s.getStart1(),
>                               Rcpp::Named("Start2") = s.getStart2() );
> }
>
> template <> SamData as( SEXP s ) {
>     Rcpp::List samL(s);
>     SamData sam;
>     sam.setChr1( Rcpp::as<std::string>(samL["Chr1"]) );
>     sam.setChr2( Rcpp::as<std::string>(samL["Chr2"]) );
>     sam.setSeq( Rcpp::as<std::string>(samL["Seq1"]) );
>     sam.setHS1( Rcpp::as<size_t>(samL["HS1"]) );
>     sam.setHS2( Rcpp::as<size_t>(samL["HS2"]) );
>     sam.setStart1( Rcpp::as<long>( samL["Start1"]) );
>     sam.setStart2( Rcpp::as<long>( samL["Start2"]) );
>     sam.setId( Rcpp::as<long>( samL["Id"]) );
>
>     return sam;
> }
>
> }
> #endif /* SAMDATA_HPP_ */
>
>
> The Rcpp package worked just fine before I started using wrap and as.
> Also, this very same code runs fine on a separate sample Rcpp project,
> where I omit the GSL (and RcppGSL) dependency (I could attach it but I
> don't know if it is allowed).
>
> Sorry if this question might sound silly (and it does to me), but is there
> any known issue or incompatibility with RcppGSL and wrap/as?
>
>
> Thanks,
> Fabio
>
>
> _______________________________________________
> 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
>



-- 
Qiang Kou
qkou at umail.iu.edu
School of Informatics and Computing, Indiana University
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20150521/6ae7f77f/attachment.html>


More information about the Rcpp-devel mailing list