From: Jim Freeze Date: 2003-05-03T09:10:47+09:00 Subject: Re: SWIG on Solaris problem On Saturday, 3 May 2003 at 8:29:47 +0900, Lyle Johnson wrote: > Jim Freeze wrote: > > > you the whole story. The real function was: > > > > fact2(int *INPUT, char **str); > > > > After reading your email, I changed this to: > > > > fact2(int *INPUT, char **INPUT); > > > > But compiling and running gives me the error: > > > > test.rb:3:in `fact2': Expected char ** (TypeError) > > from test.rb:3 > > Right. The typemaps.i file doesn't define a typemap for char **, you'll > need to roll one yourself (I will provide hints ;) > Good. :) I'll need them. > > So, I changed the header description in the .i file (without > > changing the actual function definition) to: > > > > fact2(int *INPUT, char *INPUT); > > > > Now, it appears to be getting past the initial function > > parameter passing, but I get the error: > > > > ruby test.rb > > ld.so.1: /tools/apps/ruby/ruby-1.8.0/bin/ruby: fatal: relocation error: > > file ./example.so: symbol fact2: referenced symbol not found > > Killed > > Right. SWIG interprets this line: > > int fact2(int *INPUT, char *INPUT); > > as your saying there's a real function named fact2() that expects two > arguments, a pointer-to-int and a pointer-to-char. Which of course is > not the case ;) The real fact2() expects a pointer-to-pointer-to-char as > its second argument. > > So the burning question now, is, what is that 2nd argument to fact2() > actually supposed to be? Is it intended to be an array of strings? Put > another way (and perhaps more useful), how would you expect to call this > function from Ruby? Ok, so, let me change things a bit here. The fact2 code was just to do a test to see why int* did not work. I am really trying to wrap the itkDB library. The function is defined as: dbInit(int *pnArgs, char **pString); (or dbInit(int *pnArgs, String *pString); where typdef char * String;) I expect to call it from ruby as: require 'itkdb' Itkdb.dbInit(1, "some_path") So, from what I can tell, the first arg is the number of Strings in the second String array. I don't know why the count has to be passed in as a pointer. I don't know if it is being changed. (I did not write this code, nor can I look at it.) Is that enough information? -- Jim Freeze ---------- Good day to avoid cops. Crawl to school.