[R] About dll from c++ routine

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Jun 9 18:13:50 CEST 2004


On Wed, 9 Jun 2004, Rui wrote:

> Hi folks,
>  
> My system is Windows98 + R1.9.0. 
> The path for my system is c:\perl\bin; c:\mingw\bin; c:\rtools;
> c:\windows; c:\windows\command; c:\rw1090\bin.
>  
> I created three files followed the examples in "Writing R extensions" in
> the directory c:\temp:
> // X.hh
> class X {
> public: X (); ~X ();
> };
> class Y {
> public: Y (); ~Y ();
> };
>  
> // X.cc
> #include <iostream>
> #include "X.hh"
> static Y y;
> X::X() { std::cout << "constructor X" << std::endl; }
> X::~X() { std::cout << "destructor X" << std::endl; }
> Y::Y() { std::cout << "constructor Y" << std::endl; }
> Y::~Y() { std::cout << "destructor Y" << std::endl; }
>  
>  
> // X_main.cc:
> #include "X.hh"
> extern "C" {
> void X_main () {
> X x;
> }
> } // extern "C"



> Then I followed the instructions in "R for windows FAQ" using the
> command:
> C:\temp>RCMD SHLIB X.CC X_MAIN.CC
>  
> However, I got the following message: 
> In file included from x_main.cc:2:
> x.hh:7:3: Warning: no newline at end of the file
> making convolve.d from convolve.cc
> g++   -IC: /R/RW1090/src/include -Wall -o2  -c  x.cc  -o  x.o
> In file included from x.cc:3:
> x.hh:7:3: Warning: no newline at end of the file
> make: *** No rule to make target 'x_main.o’, needed by 'X.a’. Stop
>  
> I guess I failed to get the dll file finally. 
>  
> Any suggestion would be greatly appreciated.

Add newlines at the end of your files as warned.

It would help to name your files consistently, e.g. x_main.cc and not 
X_main.cc and X_MAIN.CC.

If you follow the instructions carefully, this does work.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list