From: Eleanor McHugh Date: 2009-11-19T08:17:02+09:00 Subject: Re: How to using golang for write a xxx.so for ruby? On 18 Nov 2009, at 22:01, Jonathan Hudson wrote: > On Wed, 18 Nov 2009 20:44:20 +0900, Eleanor McHugh wrote: >> On 18 Nov 2009, at 02:50, Haoqi Haoqi wrote: >>> you may see http://golang.org >>> I want to using golang create a shared object thant can call from >>> ruby,Is it possiable? >> >> First write your shared library in go, then load it into your ruby program using either ruby/dl (part of the MRI standard library) or ruby-ffi (available as a gem and supported under both MRI and JRuby). >> >> You will also have to figure out how go mangles function names to be able to call into the library and there may well be runtime aspects of the go language which are incompatible with current ruby implementations. >> >> Happy hacking :) > > From the Go FAQ: "There is no safe way to call Go code from C or C++ yet." Indeed. But if you can build a shared library in the first place (something I can't comment on one way or the other) then both ruby/dl and ruby-ffi can attempt to load it. Whether or not that's easy or stable we'll only know for sure when someone tries :) Ellie Eleanor McHugh Games With Brains http://slides.games-with-brains.net ---- raise ArgumentError unless @reality.responds_to? :reason