From: ptkwt@... (Phil Tomson) Date: 2004-03-27T04:39:26+09:00 Subject: Re: Ruby/DL and C++ libraries In article <20040326130655.CC26.TIETEW-ML-RUBY-TALK@tietew.net>, Tietew wrote: > >On Fri, 26 Mar 2004 12:04:28 +0900 >In article >[Ruby/DL and C++ libraries] >google@redheendran.com (Bheeshmar Redheendran) wrote: > >> extern "C" void place( const std::string &text) >> { >> std::cout << text << std::endl ; >> } > : >> It works with C functions (change the "const std::string &" to a >> "const char *" and it's all good). >> >> I have a feeling this can work with the write typealias and encoding >> functions, but I'm fairly new to Ruby and would appreciate any >> pointers. > >A const std::string & is not a const char *. >C (dl.so) doesn't know how to construct/destruct std::string. > >Use C-compatible types only, or write an extension library using >Ruby APIs. SWIG is one of nice solution I think. Swig is great when you've got the source code for the library available. If you've got a shared library and an API reference for it (but no source code) then Ruby/DL seems like the way to go. Are you saying that Ruby/DL won't work with a shared library that was developed in C++? Phil