[Rd] R CMD check linking errors, when interfacing c++

Dirk Eddelbuettel edd at debian.org
Wed May 9 14:11:24 CEST 2012


On 9 May 2012 at 00:35, Zalan Szakolci wrote:
| Hi there,
| 
| I am trying to interface c++ code in R and make a package. With R CMD SHLIB
| the dll was created, but when I try R CMD check, I am getting 'undefined
| reference to..' linkage error messages.
| 
| The relevant c++ source from conf-infomap.cpp:

[...]
 
| Now when I run R CMD check, in file 00install.out I am getting the
| following linking errors:
| 
| * installing *source* package ‘DyA’ ...
| ** libs
| ** arch -
| g++ -I/usr/share/R/include -DNDEBUG      -fpic  -I -Wall -O3 -funroll-loops
| -pipe -c conf-infomap.cpp -o conf-infomap.o
| g++ -I/usr/share/R/include -DNDEBUG      -fpic  -I -Wall -O3 -funroll-loops
| -pipe -c GreedyBase.cpp -o GreedyBase.o
| g++ -I/usr/share/R/include -DNDEBUG      -fpic  -I -Wall -O3 -funroll-loops
| -pipe -c Greedy.cpp -o Greedy.o
| g++ -I/usr/share/R/include -DNDEBUG      -fpic  -I -Wall -O3 -funroll-loops
| -pipe -c Node.cc -o Node.o
| g++ conf-infomap.o GreedyBase.o Greedy.o Node.o mersenne.cpp stoc1.cpp
| userintf.cpp -lm -o conf-infomap

What is your src/Makevars file?  

This looks very wrong as you are obviously not linking against R itself.

I would recommend a good long look at both the 'Writing R Extensions' manual
as well as some of the existing CRAN packages uses C++ sources.

You can (and should) also try

    R CMD COMPILE ...

    R CMD SHLIB ...

    R CMD INSTALL ...

etc as 'R CMD check' is really only the final bit.

Dirk

-- 
R/Finance 2012 Conference on May 11 and 12, 2012 at UIC in Chicago, IL
See agenda, registration details and more at http://www.RinFinance.com



More information about the R-devel mailing list