From simon.urbanek at r-project.org  Wed May  9 15:16:38 2012
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Wed, 9 May 2012 09:16:38 -0400
Subject: [Rd] R CMD check linking errors, when interfacing c++
In-Reply-To: <CANgFBQL05eVBZwM_BUnUpKiT_sJ3aWwiq6fc02HebMRW-4kO7w@mail.gmail.com>
References: <CANgFBQK1Qn8EjSd3XsV_8NQka6X23WV_g+97mX7qWRrwtam3MA@mail.gmail.com>
	<20394.24300.191419.4870@max.nulle.part>
	<CANgFBQL05eVBZwM_BUnUpKiT_sJ3aWwiq6fc02HebMRW-4kO7w@mail.gmail.com>
Message-ID: <B74D4D2C-E572-483F-819B-649C724EC351@r-project.org>


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



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