On Tue, 12 Sep 2006, Tom McCallum wrote: > 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(); > > *** caught segfault *** > address 0x3, cause 'memory not mapped' > > **********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
Where did you read that? It is not true: you get an R error message in that case. > message and this is displayed but again the memory error occurs. > > The C++ code has been reduced to the simplest possible: > > *** helloworld.h > > extern "C" void helloworld(void); > > *** helloworld.cpp > > #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; > } > But that is the problem: .Call requires a SEXP return value from the entry point it calls. > I also wrote an R wrapper called hello as follows: > > *** helloworld.R > > 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 > -- Brian D. Ripley, [EMAIL PROTECTED] 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 ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel