The beginnig of an epic tale about how to write a Ruby C extension.
I've always wanted to try making a Ruby C Extension, for once because I wanted to know what was going on under Ruby's hood and then again because I wanted to see if writing for Ruby in C is as easy as writing in Ruby itself.
It, of course, is not.
But that's mainly because writing in C is a pain in the *#?!, not because the interfacing-with-Ruby part is hard to do.
Anyways, after coming up with a pure Ruby gem for wildcard matching (Joker) I thought: Hey, that would make an excellent C extension!
So I ventured out on a journey to conquer the Ruby C extension world -- or at least leave a footprint on its ground.
This article and it's followers are my idea of a map of my journey and the holes I fell in and stones I tripped over, so you won't have to.
I hope it helps someone.
One of the most important things when developing Ruby C extensions is to get your toolset right. If you start out with none or the wrong tools, you're sooner or later going to get lost in the compiler jungle.
So you better plan ahead and have them installed.
Here's a list of what I recommend:
Great! Now run off to your nearest package manager and get them all! Meanwhile, I'll finish the next part of my little narration...
gem install rake-compiler rake-tester
for valgrind and gcc, please use your OS package manager or get some binaries on the net.