Re: question re. shared libraries
rif <[email protected]> Mon, 26 Apr 2004 16:15:27 -0400
| Newsgroups | gmane.lisp.uffi.general |
|---|---|
| Message-ID | <[email protected]> |
I realize that my previous email may have been insufficiently clear.
My goal is to build a CL to R gateway on top of UFFI (R is a very nice
package for doing statistics and scientific graphics; there is a
Python to R gateway called rpy that I'm attempting to use as a
template). I have the following C program:
#include <stdio.h>
#include <R.h>
int main(int argc, char **argv) {
char *Rargv[] = {"ctest", "-q", "--vanilla"};
int retval;
setenv("R_HOME", "/usr/local/lib/R", 1);
retval = Rf_initEmbeddedR( 3, Rargv );
printf("R started, retval = %d.\n");
return 0;
}
This program compiles, and I link it against the R shared library, and
it runs successfully (the return value is 1). My first subgoal is to
duplicate this behavior in CL. I load the shared library and I
declare the function as:
(def-function ("Rf_initEmbeddedR" start-r)
((argc :int)
(argv (* :cstring)))
:returning :int)
Unfortunately, my best attempts so far result in an arithmetic error
FLOATING-POINT-INVALID-OPERATION signalled under about seven "Foreign
function call land" stack frames, which of course I have no way to
debug. (I say this is my best attempt because before I realized that
I needed to set R_HOME, calling the function caused the process and CL
to crash, which I consider to be worse.)
I believe I've got the declaration correct --- as a test, I wrote a
small C program that has the same form of the declaration and just
counts up all the characters in the argument strings, and that works
fine. Given that I've got a small C program that calls the shared
library in question, I'm guessing it has to be something relating to
the shared libraries.
Any thoughts, ideas or advice are most appreciated.
Cheers,
rif