I’m building a native C extension Ruby gem for generating unique identifiers (found here). I’d like the library to use libuuid if possible (through C extensions) and fall back to a simple Ruby implementation. I currently have both the C and Ruby code for generating the UUID, however I can’t figure out how to configure a successful fallback. Any ideas?
I’m building a native C extension Ruby gem for generating unique identifiers (found here
Share
The
have_librarymethod has a return value:So you should be able to do this:
And then set up your C to use libuuid if
USE_RUBY_UUIDis not defined and call into the Ruby UUID library if it is defined.Oddly enough, the
have_headerandhave_funcmethods inmkmf.rbadd macros for you:but
have_librarymakes you do it yourself.