I'm being thick here, but could someone help me out with
Pickaxe chapter 17?
I'm trying to get the first example to work
(can't quote a page number as I'm reading it at work today online,
but the line:
"We can use the C version of the code in Ruby simply by require-ing it
dynamically at runtime (on most platforms)."
is confusing me. I assume you need to compile the c source to
a library - shared or otherwise? That step wasn't mentioned though.
Does the following look like it'd work?
(I'm fairly sure it's failing to require the file, but I
may as well see what's wrong with it before I try to use it).
So far I've got to:
rasputin@shrike cruby$ gcc -c -o Test.o -I \
/usr/local/lib/ruby/1.6/i386-freebsd4/ simple.c
rasputin@shrike cruby$ ls
Test.o simple.c test.rb
rasputin@shrike cruby$ file Test.o
Test.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (FreeBSD),
not stripped
rasputin@shrike cruby$ cat test.rb
#! /usr/local/bin/ruby -I.
require "Test" # this is wrong?
t = Test.new
t.add("Dog food", 3 , 4 , 5);
rasputin@shrike cruby$ ./test.rb
./test.rb:3:in `require': No such file to load -- Test (LoadError)
from ./test.rb:3
--
Rasputin :: Jack of All Trades - Master of Nuns