On 3/20/06, killy-kun <killy-kun / wanadoo.fr> wrote:
> Mark Volkmann wrote:
> > On 3/20/06, killy-kun <killy-kun / wanadoo.fr> wrote:
> >
> >>I would like to use the c++ string type as a parameter of function
> >>return of some c++ functions used in a ruby module, made with swig.
> >>
> >>Here is a simple example I tried to use the string type :
> >>
> >>#-----------------
> >>%module str
> >>
> >>%inline %{
> >>
> >>// pour tester les string
> >>
> >>#include <string>
> >>
> >>using namespace std;
> >>
> >>string fctBidon (string s)
> >>{
> >>        string res;
> >>        res = s + " salt bidon";
> >>        return res;
> >>}
> >>
> >>string bidon()
> >>{
> >>        string res = "bouh";
> >>        return res;
> >>}
> >>
> >>%}
> >>#-----------------
> >>
> >>But when I use it, here are the errors I get :
> >>
> >>#-----------------
> >>[eurubyt:24] bidon
> >>  ==> #<SWIG::TYPE_p_string:0xb7f080e0>
> >>[eurubyt:25] bidon.class
> >>  ==> SWIG::TYPE_p_string
> >>[eurubyt:26] fctBidon("bb")
> >>TypeError: in method 'fctBidon', argument 1 of type 'string'
> >>         from (irb):26:in `fctBidon'
> >>         from (irb):26
> >>#-----------------
> >>
> >>That means the c++ string type isn't considered as the ruby String class...
> >>
> >>Anybody knows how I can make this work ? I would like the c++ string
> >>type to be considered as the ruby String class...
> >
> >
> > There's an example that does this near the end of a presentation I
> > gave. You can get a PDF of the presentation at
> > http://groups.yahoo.com/group/stlruby/files/. Look for the file
> > RubyTools.pdf.
> >
> > --
> > R. Mark Volkmann
> > Object Computing, Inc.
> >
> >
>
> Thank you very much.
> But the problem doesn't seem tobe resolved :/
> The only thing I had to add seems to be :
> %include "std_string.i"
>
> I did so, the compilation goes well, and seems to take the file into
> account.
> But the effect is still exactely the same...
>
> I tried your example, but had the following error when running the
> main.rb file :
>
> ruby: symbol lookup error: ./RubyPerson.so: undefined symbol:
> _ZN6PersonC1ERKSs

I'm not sure what else to suggest. If you'd like, tar up your code and
your build script, email it to me, and I'll try to get it to run.

--
R. Mark Volkmann
Object Computing, Inc.