# Loading an extension on statically linked ruby

**URL:** <https://www.ruby-forum.com/t/loading-an-extension-on-statically-linked-ruby/156956>\
**Category:** Ruby\
**Created:** [January 5, 2009, 8:45pm UTC](https://www.ruby-forum.com/t/loading-an-extension-on-statically-linked-ruby/156956 "2009-01-05T20:45:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Edgardo\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@Edgardo\_H](https://www.ruby-forum.com/u/Edgardo_H)\
**Post date:** [January 5, 2009, 8:45pm UTC](https://www.ruby-forum.com/t/loading-an-extension-on-statically-linked-ruby/156956/1 "2009-01-05T20:45:37Z")

</div>

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
