Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Writing a C extension for Ruby to parse and unparse OSC messages

This is a note for myself more than anything. I've started on a wrapper for the rtosc library

The aim is to make a gem called FastOsc that will have two methods

FastOsc.serialise(["/aa", "foo", "bar"]) #=> "/aa\x00ss\x00\x00foo\x00bar\x00"
FastOsc.deserialise("/aa\x00ss\x00\x00foo\x00bar\x00") #=> ["foo", "bar"]

This followed from the rtosc library author giving me a really helpful response.

A selection of sources that helped with this

Linking static/dynamic libraries dyld lazy symbol binding failed: symbol not found (I was linking the headers but not the libs .a file) Super useful post on setting up extconf.rb to find headers and libs implicit self and "what does VALUE return?"

Ruby C API guides

This jcoglan blog was super useful at bootstrapping a gem with ext and rake-compile Tenderlove blog posts The guide (README.EXT) a bit out of date now pdf guide Pickaxe section


xml4r (early nokogiri?) example of StringValuePtr for constant char array

FFI stuff that I didn't end up going with FFI over liblo Flexible array members (size_t) seem tricky in FFI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment