From ligges at statistik.uni-dortmund.de  Tue May 18 16:48:45 2004
From: ligges at statistik.uni-dortmund.de (Uwe Ligges)
Date: Tue May 18 16:48:04 2004
Subject: [Rd] R and  C++ code
In-Reply-To: <004901c43ce5$bad36510$f13731c1@Cysteine>
References: <001f01c43ce2$fdd42230$f13731c1@Cysteine>	<Pine.LNX.4.51.0405181630230.9672@artemis.imbe.med.uni-erlangen.de>
	<004901c43ce5$bad36510$f13731c1@Cysteine>
Message-ID: <40AA224D.7030903@statistik.uni-dortmund.de>

Sandrine Coelho wrote:
> I work under windows XP, so i haven't file "X_main.so".

Well,

  1. have you compiled with R CMD SHLIB (or Rcmd SHLIB, if R<1.9.0)?
  2. have you used dyn.load() to load the corresponding dll file?

Anyway, please read "Writing R Extensions" for more details.

Uwe Ligges



> Torsten Hothorn wrote:
> 
>>>Hello,
>>> I want to use a C++ library under R, but I have problems.
>>>I have readen the manual: "Writing R Extensions" and the setion "
>>>Interfacing C++ code". I have created :
>>>//X.cpp
>>>#include "X.h"
>>>#include <iostream>
>>>
>>>X::X()
>>>{
>>>  std::cout << "constructor X" << std::endl;
>>>}
>>>
>>>X::~X()
>>>{
>>>}
>>>
>>>
>>>//X.h
>>>#ifndef X_H
>>>#define X_H
>>>
>>>class  X
>>>{
>>>   public:
>>> X();
>>>
>>> ~X();
>>>};
>>>#endif
>>>
>>>//X_main.cpp
>>>#include "X.h"
>>>
>>>extern "C" {
>>>
>>>void X_main(){
>>>X x;
>>>}
>>>}
>>>
>>>
>>>//essai.R
>>
>>did you load the shared library via
>>
>>dyn.load("X_main.so")
>>
>>?
>>
>>Torsten
>>
>>
>>>foo<-function()
>>>{.C("X_main");}
>>>
>>>When I execute the file essai.R, the R console returns:
>>>
>>>Error in .C("X_main") : C function name not in load table.
>>>
>>>If you can help me.
>>>Thank you.
>>>
>>>Sandrine
>>>
>>>______________________________________________
>>>R-devel@stat.math.ethz.ch mailing list
>>>https://www.stat.math.ethz.ch/mailman/listinfo/r-devel
> 
> 
> ______________________________________________
> R-devel@stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-devel


[Rd] R and C++ code
Uwe Ligges