2

I've written a few Ruby native extensions, the usual deal is to have a "target name", foo say, then have a file ext/foo/foo.c which defines Init_foo. I have a need (see below) to have a different filename, ext/foo/bar.c say, which defines Init_foo instead. Is this even possible?

Why on Earth do this

I have an existing Gem called foo, it wraps an existing C library libfoo which contains a file foo.c, both are stable and have users. I don't want users of the gem to have to install libfoo themselves, instead to have it embedded in the gem itself. This is the "packaged source" strategy as described here. When trying to compile with this strategy I get errors about foo.c being duplicated (as it is). If I could get the "extension file" renamed as above, that should remove this roadblock.

jjg
  • 907
  • 8
  • 18
  • 1
    This case has been warned at the link you referred to in the "What can go wrong section". How costly would it be to change the name only in the packaged gem? – Patrick Feb 23 '23 at 17:40
  • That would be pretty painful I think, it seems less so to rename the `foo.c` from the embedded library (MakeMakefile just uses a wildcard to generate the list of files to compile), it does add an extra step to the build (after copying in the library files) and feels a by grimy, but does at leas compile. – jjg Feb 23 '23 at 19:13

0 Answers0