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

Simon Urbanek simon.urbanek at r-project.org
Wed May 9 15:16:38 CEST 2012


On May 9, 2012, at 9:10 AM, Zalan Szakolci wrote:

> Hi,
> 
> Thanks for the suggestions. I've forgotten to  point out, that
> 
> R CMD COMPILE and
> R CMD SHLIB
> 
> works fine, the dll file was indeed created. I get these undefined
> references when I'm trying to run R CMD INSTALL.
> 

... which means you are probably doing something silly in Makevars or Makefile (ideally, you should not have either) -- and that's why Dirk was asking you.


> I've read through the "Writing R extensions" and the archives, but I really
> don't know what am I doing wrong.
> 
> More suprising, when I run the same package in windows with R CMD check,
> the dll for src-i386 was created, but not the 64 -bit, i'm getting: sorry,
> 64 bit compilation not supported (or someting similar)
> 

You have the wrong toolchain on your PATH (see recent question here).

Cheers,
Simon



> If anyone have an idea, comments welcome.
> 
> Thanks,
> 
> Zalan
> 
> On 9 May 2012 14:11, Dirk Eddelbuettel <edd at debian.org> wrote:
> 
>> 
>> 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
>> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



More information about the R-devel mailing list