Never mind, need to use -rdynamic -Wl,-export-dynamic (actually
Config::CONFIG['LDFLAGS']) when linking.

Paul

On Wed, Nov 26, 2008 at 11:30:55PM +0900, Paul Brannan wrote:
> I've copied code from main.c in an attempt to embed the ruby interpreter
> in a very simple program, but I'm getting an error:
> 
> [pbrannan@zem emb]$ cat emb.c
> #include <ruby.h>
> 
> int main(int argc, char * argv[])
> {
>   ruby_sysinit(&argc, &argv);
>   RUBY_INIT_STACK;
>   ruby_init();
>   void * node = ruby_options(argc, argv);
>   ruby_run_node(node);
> }
> 
> [pbrannan@zem emb]$ gcc \
> -I/usr/local/include/ruby1.9-1.9.0 \
> -I/usr/local/include/ruby1.9-1.9.0/i686-linux \
> -I/usr/local/include/ruby1.9-1.9.0 \
> -I/usr/local/include/ruby1.9-1.9.0/i686-linux \
> emb.c -o emb \
> -lpthread -lrt -ldl -lcrypt -lm \
> -lc -Wl,-R -Wl,/usr/local/lib \
> -L/usr/local/lib -lruby1.9-static
> [pbrannan@zem emb]$ ./emb
> ./emb: error while loading shared libraries: /usr/local/lib/ruby1.9/1.9.0/i686-linux/enc/encdb.so: undefined symbol: rb_encdb_declare
> [pbrannan@zem emb]$ nm emb | grep rb_encdb_declare
> 08104730 T rb_encdb_declare
> [pbrannan@zem emb]$ nm `which ruby1.9` | grep rb_encdb_declare
> 08112110 T rb_encdb_declare
> 
> Any idea where I'm going wrong?
> 
> Paul
> 
>