Loading an extension on statically linked ruby


#1

Hi guys,

I’ve configured and built the Ruby interpreter with the following
options:

CFLAGS=-static ./configure --with-static-linked-ext --disable-shared –
without-openssl --without-tk --prefix=/opt/ruby

I also have an extension which was built with the following commands

ruby extconf.rb

make

gcc -I. -I/opt/ruby/lib/ruby/1.8/i686-linux -I/opt/ruby/lib/ruby/1.8/
i686-linux -I. -D_FILE_OFFSET_BITS=64 -fPIC -static -c clicmd.c
gcc -shared -o clicmd.so clicmd.o -L. -L/opt/ruby/lib -Wl,-R/opt/ruby/
lib -L. -rdynamic -Wl,-export-dynamic -ldl -lcrypt -lm -lc

When I run the script that requires this library I get an undefined
symbol error:

ruby hpm.rb

./clicmd.so: ./clicmd.so: undefined symbol: rb_cObject - ./clicmd.so
(LoadError)

Any hints on how to solve this issue? Can I use dynamic extensions if
I have built ruby with statically linked extensions? Do I need to
statically link my extension to ruby?

Thanks in advance,
Edgardo