How to using golang for write a xxx.so for ruby?

E

Eleanor McHugh

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 :)


Ellie

Eleanor McHugh
Games With Brains
http://slides.games-with-brains.net
 
J

Jonathan Hudson

=20
First write your shared library in go, then load it into your ruby progra=
m using either ruby/dl (part of the MRI standard library) or ruby-ffi (avai=
lable as a gem and supported under both MRI and JRuby).
=20
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 l=
anguage which are incompatible with current ruby implementations.
=20
Happy hacking :)
=20
=20
Ellie
=20

=46rom the Go FAQ: "There is no safe way to call Go code from C or C++
yet."

-jh
 
E

Eleanor McHugh

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).able to call into the library and there may well be runtime aspects of =
the go language which are incompatible with current ruby =
implementations.
=20
=46rom 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top