Include C code in a FFI-based gem

Hi,

I would like to build a gem that contains C source code, but I don’t want to use C extensions. I’d like to use FFI instead. Is there a way to build a shared library usable by FFI when installing a gem?

Denis

just compile it to a dll and distribute it with that. I'm not sure if
mkmf allows for (easy) dll creation on the fly though...

···

--
Posted via http://www.ruby-forum.com/.

Denis Defreyne wrote in post #1058861:

Hi,

I would like to build a gem that contains C source code, but I dont want
to use C extensions. Id like to use FFI instead. Is there a way to build
a shared library usable by FFI when installing a gem?

Take a look on how one of Ruby's own test builds a DLL using extconf.rb:
https://github.com/ruby/ruby/blob/trunk/ext/-test-/win32/dln/extconf.rb

You can create a shared object for any platform, and during gem install
it will be copied to "lib" directory (in theory, haven't tried)

Explore that idea and let us know how it goes.

Good luck,

···

--
Luis Lavena

--
Posted via http://www.ruby-forum.com/\.