[Rcpp-devel] Error linking: Undefined reference to...

Bjørn Skogtrø bjorn.skogtro at gmail.com
Thu Sep 8 10:36:52 CEST 2011


Hi guys.

First off, thanks for a nice piece of software.

Now to the issue at hand:

I'm trying to compile and link the package obtained using
Rcpp.package.skeleton(...) (out of the box). I'm running R 2.13.1, with Rcpp
0.9.6 on a Windows XP machine.

The first problem I ran into was how the package-libs variable PKG_LIBS was
pasted into the g++ string for compiling:

g++ -shared -s -static-libgcc -o processes.dll tmp.def rcpp_hello_world.o
rcpp_module.o C:/Program Files/R/R-2.13.1/library/Rcpp/lib/i386/libRcpp.a
-LC:/PROGRA~1/R/R-213~1.1/bin/i386 -lR
g++.exe: C:/Program: No such file or directory
g++.exe: Files/R/R-2.13.1/library/Rcpp/lib/i386/libRcpp.a: No such file or
directory
ERROR: compilation failed for package 'processes'
* removing 'D:/Documents/Eclipse/processes.Rcheck/processes'

As you can see, paths with spaces in them is not cool.I resolved this by
overriding it in makevars.win by hard-coding it, so my makevars.win looks
like

## Use the R_HOME indirection to support installations of multiple R version
## PKG_LIBS = $(shell "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" -e
"Rcpp:::LdFlags()")
PKG_LIBS = $("C:/PROGRA~1/R/R-2.13.1/library/Rcpp/lib/i386/libRcpp.a")

Compiling then works fine, and spits out the files rcpp_module.o and
rcpp_hello_world.o. The problem then is linking, which complains over
"undefined reference":

* installing *source* package 'processes' ...
** libs
cygwin warning:
  MS-DOS style path detected: C:/PROGRA~1/R/R-213~1.1/etc/i386/Makeconf
  Preferred POSIX equivalent is:
/cygdrive/c/PROGRA~1/R/R-213~1.1/etc/i386/Makeconf
  CYGWIN environment variable option "nodosfilewarning" turns off this
warning.
  Consult the user's guide for more details about POSIX paths:
    http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
g++ -shared -s -static-libgcc -o processes.dll tmp.def rcpp_hello_world.o
rcpp_module.o -LC:/PROGRA~1/R/R-213~1.1/bin/i386 -lR
rcpp_hello_world.o:rcpp_hello_world.cpp:(.text+0x66): undefined reference to
`Rcpp::RObject::setSEXP(SEXPREC*)'
rcpp_hello_world.o:rcpp_hello_world.cpp:(.text+0x71): undefined reference to
`void Rcpp::internal::r_init_vector<16>(SEXPREC*)'
rcpp_hello_world.o:rcpp_hello_world.cpp:(.text+0x148): undefined reference
to `Rcpp::RObject::setSEXP(SEXPREC*)'
rcpp_hello_world.o:rcpp_hello_world.cpp:(.text+0x1a7): undefined reference
to `Rcpp::RObject::setSEXP(SEXPREC*)'

I'm assuming that these two errors are somewhat related, but can't figure it
out (the compile processs running R CMD check is a bit intransparent to me).
I should mention that this exact procedure worked fine until I upgraded from
2.13.0 to 2.13.1 yesterday.

Any clues on what to look at??

Thanks!

BR,
Bjørn


-- 
Up, down, turn around
Please dont let me hit the ground
Tonight I think Ill walk alone
Ill find my soul as I go home.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20110908/2d83c4e0/attachment.htm>


More information about the Rcpp-devel mailing list