[Rcpp-devel] Building shared libs with Rcpp does not work as before after Debian update ( function 'dataptr' not provided by package 'Rcpp' )

Dirk Eddelbuettel edd at debian.org
Wed Mar 19 15:19:48 CET 2014


On 19 March 2014 at 13:32, Andreas Recke wrote:
| I found the problem. 

Very good :)  And thanks for reporting back here.

| The solution is as always: simple and stupid, and difficult to find.
| When using my shared library, I used to do this:
| >dyn.load("test.so")
| >.Call("test", x_ = 2, y_ = 3)
| And got the error: function 'dataptr' not provided by package 'Rcpp'

Well I think I suggested three times not to do that dyn.load / .Call dance.

We had inline for four or so years which already does it for you.  We then
added sourceCpp() etc which is even easier.

Please use Rcpp Attributes (or at least cxxfunction()).  

Friends don't let friends use dyn.load() anymore.
 
| I did not load the Rcpp library for that, because all the Rcpp routines
| were already linked into my test.so!
| The solution now is to do
| >require("Rcpp")
| before. And everything works!

That will deal with the Rcpp instantiation.

All this will also be taken care of when you write a package ...
 
| Maybe it is equally simple to include the boost libraries into R, to
| improve the portability of my final package ...

... which will deal with this.  Boost in templates-only mode is taken care of
by the BH package. All you need there is a LinkingTo: BH in addition to Rcpp.

But you seem to be linking with Boost System and Boost Thread. At a package
level that is pretty easy (via configure and/or environment variables) and I
guess I should write up something for the Rcpp Gallery on how I'd do it on
the fly: either via PKG_LIBS as I mentioned in the thread or possibly via an
on-the-fly plugin.

Dirk

| 
| All the best,
| Andreas
| 
| 
| 
| 
| 
| 
| On 18.03.2014 15:45, Andreas Recke wrote:
| > Hi,
| >
| > maybe I can add some more details about my problem. It has been
| > addressed before at stackoverflow:
| >
| > http://stackoverflow.com/questions/21657575/what-does-this-mean-in-lme4-function-dataptr-not-provided-by-package-rcpp
| >
| > with the question:
| > "I'm trying to do LMM using lme4, and this message pops up:
| >
| > Error in initializePtr() : function 'dataptr' not provided by package 'Rcpp'
| >
| > What should I do?"
| >
| > As proposed there in the responses, I reinstalled Rcpp, RcppArmadillo
| > and RcppEigen (in this order) from source packages.
| > However, when I look with nm into RcppEigen.so in the library folder, I
| > find the following:
| >
| > andreas at persephone:~/R/x86_64-pc-linux-gnu-library/3.0/RcppEigen/libs$
| > nm RcppEigen.so | grep " u "
| >
| >
| >
| >
| > 0000000000238e70 u _ZGVZ13error_occuredvE3fun
| > 0000000000238e80 u _ZGVZ19reset_current_errorvE3fun
| > 0000000000238bb8 u _ZGVZ20rcpp_get_stack_tracevE3fun
| > 0000000000238bb0 u _ZGVZ20rcpp_set_stack_traceP7SEXPRECE3fun
| > 0000000000238e60 u _ZGVZ22rcpp_get_current_errorvE3fun
| > 0000000000238ba0 u _ZGVZ7dataptrP7SEXPRECE3fun
| > 0000000000238ba8 u _ZGVZ8demangleRKSsE3fun
| > 0000000000238e90 u _ZGVZN4Rcpp8internal18get_Rcpp_namespaceEvE3fun
| > 0000000000238e10 u _ZZ13error_occuredvE3fun
| > 0000000000238e30 u _ZZ19reset_current_errorvE3fun
| > 0000000000238b80 u _ZZ20rcpp_get_stack_tracevE3fun
| > 0000000000238b70 u _ZZ20rcpp_set_stack_traceP7SEXPRECE3fun
| > 0000000000238e00 u _ZZ22rcpp_get_current_errorvE3fun
| > 0000000000238b60 u _ZZ7dataptrP7SEXPRECE3fun                  <-----
| > here is the missing function
| > 0000000000238b90 u _ZZ8demangleRKSsE3fun
| > 0000000000238e20 u _ZZN4Rcpp8internal18get_Rcpp_namespaceEvE3fun
| > 0000000000238e40 u
| > _ZZN5Eigen8internal20manage_caching_sizesENS_6ActionEPlS2_E13m_l1CacheSize
| > 0000000000238e50 u
| > _ZZN5Eigen8internal20manage_caching_sizesENS_6ActionEPlS2_E13m_l2CacheSize
| > 0000000000033708 u
| > _ZZN5Eigen8internal23triangular_solve_vectorIddlLi1ELi1ELb0ELi0EE3runElPKdlPdE10PanelWidth
| > 0000000000033718 u
| > _ZZN5Eigen8internal23triangular_solve_vectorIddlLi1ELi2ELb0ELi0EE3runElPKdlPdE10PanelWidth
| > 0000000000033700 u
| > _ZZN5Eigen8internal23triangular_solve_vectorIddlLi1ELi2ELb0ELi1EE3runElPKdlPdE10PanelWidth
| > 00000000000336f8 u
| > _ZZN5Eigen8internal23triangular_solve_vectorIddlLi1ELi5ELb0ELi0EE3runElPKdlPdE10PanelWidth
| > 00000000000336f0 u
| > _ZZN5Eigen8internal23triangular_solve_vectorIddlLi1ELi6ELb0ELi1EE3runElPKdlPdE10PanelWidth
| > 0000000000033710 u
| > _ZZN5Eigen8internal32triangular_matrix_vector_productIlLi2EdLb0EdLb0ELi0ELi0EE3runEllPKdlS4_lPdlRS3_E10PanelWidth
| >
| >
| > This completely fits the above quoted error message. But I don't know
| > how to solve this. Can you help?
| >
| > Best regards,
| > Andreas
| >
| >
| >
| >
| >
| >
| >
| > On 18.03.2014 11:43, Andreas Recke wrote:
| >> Hi,
| >>
| >> until recently, I used a very simple mechanism to compile and link my
| >> C++/Rcpp/RcppArmadillo code for using it in R.
| >> Since the last update, however, something has changed with the linking,
| >> and the Rcpp shared library is not linked to
| >> the final libary as before.
| >> My question is, whether I need to change the my code to take these
| >> changes into account? Is there a compatibility problem
| >> with earlier versions of R and Rcpp?
| >> I would like to have at least the option to use the command line to
| >> compile my code and to have it working even with different
| >> versions of R and Rcpp, especially because I found a way to use the
| >> THRUST library for parallel computing with Rcpp, Boost and R.
| >>
| >> So here is my problem:
| >>
| >>  ******************* test.cpp ***************
| >>  #include <iostream>
| >>  #include <iomanip>
| >>  #include <cmath>
| >>  #include <RcppArmadillo.h>
| >>
| >>  using namespace Rcpp;
| >>
| >>  double norm(double x, double y)
| >>  {
| >>      return sqrt(x*x + y*y);
| >>  }
| >>
| >>  RcppExport SEXP norm_wrapper(SEXP x_,SEXP y_)
| >>  {
| >>    // step 0: convert input to C++ types
| >>    double x = as<double>(x_), y= as<double>(y_);
| >>    // step 1: call the underlying C ++ function
| >>    double res = norm (x,y);
| >>    // step 2: return the result as a SEXP
| >>    return wrap(res);
| >>  }
| >>  *******************
| >>
| >> *************** my makevars ****************
| >>
| >> PKG_CXXFLAGS=$(shell Rscript -e "Rcpp:::CxxFlags()") $(shell Rscript -e "RcppArmadillo:::CxxFlags()")
| >> PKG_LIBS=$(shell Rscript -e "Rcpp:::LdFlags()") $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) -lboost_system -lboost_thread
| >>
| >> ********************************************
| >>
| >>
| >> ************* in bash, I compile with ***********
| >> R CMD SHLIB test.cpp
| >>
| >> ****************************************************
| >>
| >> ************* in R console ****************
| >>
| >>> dyn.load("test.so")
| >>> .Call("norm_wrapper", x_=2, y_=3)
| >> and I get the error message, that function "dataptr" is not provided by
| >> package "Rcpp" ...
| >>
| >> ******************************************
| >> looking at test.so with nm , function "dataptr" is marked as unknown
| >>
| >> Until recently, the above described procedure worked fine. Maybe it is
| >> possible to keep it available for
| >> compatibility reasons.
| >>
| >> Andreas
| >>
| >>
| >> By the way: I have R version 3.0.3 (2014-03-06) -- "Warm Puppy" on
| >> x86_64-pc-linux-gnu (64-bit), with Rcpp 0.11.1 from 3/12/2014
| >>
| 
| --
| Dr. Andreas Recke
| Facharzt
| Klinik für Dermatologie, Allergologie und Venerologie
| Universitätsklinikum Schleswig-Holstein, Campus Lübeck
| Ratzeburger Allee 160
| 23538 Lübeck
| Tel.: +49 451 500 2530
| Fax.: +49 451 500 2981
| 
| [http://www.uksh.de/skin/uksh/tpl/infoportal/img/uk-sh_logo.gif]
| 
| Universitätsklinikum Schleswig-Holstein
| Rechtsfähige Anstalt des öffentlichen Rechts der Christian-Albrechts-Universität zu Kiel und der Universität zu Lübeck
| 
| Vorstandsmitglieder: Prof. Dr. Jens Scholz (Vorsitzender), Peter Pansegrau, Christa Meyer
| Vorsitzender des Aufsichtsrates: Rolf Fischer
| Bankverbindungen:
| Förde Sparkasse BLZ 210 501 70 Kto.-Nr. 100 206, IBAN: DE14 2105 0170 0000 1002 06 SWIFT/BIC: NOLA DE 21 KIE
| Commerzbank AG BLZ 230 800 40 Kto.-Nr. 300 041 200, IBAN: DE17 2308 0040 0300 0412 00 SWIFT/BIC: DRES DE FF 230
| 
| Diese E-Mail enthält vertrauliche Informationen und ist nur für die Personen bestimmt, an welche sie gerichtet ist.
| Sollten Sie nicht der bestimmungsgemäße Empfänger sein, bitten wir Sie, uns hiervon unverzüglich zu unterrichten und die E-Mail zu vernichten.
| Wir weisen darauf hin, dass der Gebrauch und die Weiterleitung einer nicht bestimmungsgemäß empfangenen E-Mail und ihres Inhalts gesetzlich verboten sind und ggf. Schadensersatzansprüche auslösen können.
| _______________________________________________
| 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

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com


More information about the Rcpp-devel mailing list