[Rd] Memory problems with a custom R package

From: Tom McCallum <tom.mccallum_at_levelelimited.com>
Date: Tue 12 Sep 2006 - 10:39:41 GMT


Hi everyone,

I have been attempting to build a very simple R package interfacing with some very simple C++ code. Everything I try though results in the function working but on return it produces a memory error. Here is the output:

***********OUTPUT***************************

> library(MyPackage)
> hello();

**********END OUTPUT*************************

I have read that some time this occurs because it cannot find the function in the shared library but I have tested this theory with a simple text message and this is displayed but again the memory error occurs.

The C++ code has been reduced to the simplest possible:

extern "C" void helloworld(void);

#include <iostream>
#include "helloworld.h"

void helloworld(void) {

//	This was my test line that was displayed as described above.
//      std::cout << "My first R Package Test." << std::endl;
}

I also wrote an R wrapper called hello as follows:

hello <- function()
{
  .Call("helloworld", PACKAGE="MyPackage"); }

The namespaces file (NAMESPACE) is as follows:

useDynLib(MyPackage)
export(hello)

I have compared mine against other package sources available that do the same thing and cannot find the key difference.

Thank you for your help in advance,

Tom



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Tue Sep 12 20:48:04 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 12 Sep 2006 - 13:30:06 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.