[Rcpp-devel] Rcpp upgrading legacy code linking error

Douglas Bates bates at stat.wisc.edu
Wed Mar 9 17:57:10 CET 2011


On Wed, Mar 9, 2011 at 9:14 AM, Dahir Alihassan <da288 at cantab.net> wrote:
> Hi,
>
> I am posting here upon Dirk's suggestion, as I understand this is well
> attended to and I'd be grateful for any help. I am taking over a project
> which involves upgrading to the latest version of Rcpp and thus I have to
> upgrade all the old style API calls (which is compatible with the Classic
> version I believe). The compile works fine but the errors arise on linking
> against the resulting \inst\libs\RLinkage.dll.
>
> I have manged to convert a lot of the code (mainly using Rcpp::List to
> extract and pack incoming and outgoing function parameters but also a bit
> of exception handling) but I simply keep getting "undefined reference"
> errors on linking. The build log after compiling says "Linking console
> executable" and this is where it list undefined references in the
> *.o:*.cpp files to:
>
> 1.Rprintf or Rf_error and forward_exception_to_r.
> 2.R_NilValue
> 3.Rf_install

Except for forward_exception_to_r those symbols are part of the R API.
 Can you provide the output from the compilation of the package?  The
last line of the compilation should look like

g++ -shared -o minqa.so altmov.o bigden.o biglag.o bobyqa.o bobyqb.o
lagmax.o minqa.o newuoa.o newuob.o prelim.o rescue.o trsapp.o trsbox.o
trstep.o uobyqa.o uobyqb.o update.o updatebobyqa.o
-L/home/bates/R/x86_64-pc-linux-gnu-library/2.12/Rcpp/lib -lRcpp
-Wl,-rpath,/home/bates/R/x86_64-pc-linux-gnu-library/2.12/Rcpp/lib
-lgfortran -lm -L/usr/lib64/R/lib -lR

and the important part is the -lR at the end.  That is where those
symbols (except for forward_exception_to_r) are defined.

> I do have #include <Rcpp.h> (there was a series of errors that were
> occuring because I had included iostream before Rcpp, which was
> strange). I've tried looking at the RCPP PDF but can't seem to figure it
> out. I also tried to ensure that R.dll is on my PATH (C:\Program
> Files\R\R-2.12.1\bin\x64). I am using Code::Blocks 10.05 IDE with RTools
> installed and Mingw64 referenced explicitly in the toolchain (and
> correctly Autodetected as the compiler). I'd be extremelt grateful for any
> heads up.
> Thanks!
>
>
>
> _______________________________________________
> 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
>


More information about the Rcpp-devel mailing list