[Ruby] Native extensions on OS X

Aaron Patterson aaron at tenderlovemaking.com
Sun Jul 8 19:21:35 PDT 2007


Alright, I'm not sure what I'm doing wrong....

I'm writing a native extension that loads a shared object.  But for some
reason, it can't find the symbols from the shared object!  Everything
works on linux, but for some reason OS X doesn't seem to work.

Here's my compile output:

[aaron at aaron-pattersons-powerbook58 ext]$ make
gcc -fno-common  -arch ppc -g -Os -pipe -fno-common  -arch ppc -pipe -pipe -fno-common  -I. -I/usr/lib/ruby/1.8/powerpc-darwin8.0 -I/usr/lib/ruby/1.8/powerpc-darwin8.0 -I. -DHAVE_LAME_LAME_H  -c decoder.c
gcc -fno-common  -arch ppc -g -Os -pipe -fno-common  -arch ppc -pipe -pipe -fno-common  -I. -I/usr/lib/ruby/1.8/powerpc-darwin8.0 -I/usr/lib/ruby/1.8/powerpc-darwin8.0 -I. -DHAVE_LAME_LAME_H  -c get_audio.c
gcc -fno-common  -arch ppc -g -Os -pipe -fno-common  -arch ppc -pipe -pipe -fno-common  -I. -I/usr/lib/ruby/1.8/powerpc-darwin8.0 -I/usr/lib/ruby/1.8/powerpc-darwin8.0 -I. -DHAVE_LAME_LAME_H  -c lollame.c
gcc -fno-common  -arch ppc -g -Os -pipe -fno-common  -arch ppc -pipe -pipe -fno-common  -I. -I/usr/lib/ruby/1.8/powerpc-darwin8.0 -I/usr/lib/ruby/1.8/powerpc-darwin8.0 -I. -DHAVE_LAME_LAME_H  -c syncword.c
cc -dynamic -bundle -undefined suppress -flat_namespace  -L"/usr/lib" -o lollame.bundle decoder.o get_audio.o lollame.o syncword.o  -lpthread -ldl -lobjc  


When I run my test script:

dyld: NSLinkModule() error
dyld: Symbol not found: _lame_get_num_channels
  Referenced from: ./lollame.bundle
  Expected in: flat namespace

Trace/BPT trap

My dlopen line from my code:

    dlopen("libmp3lame.dylib", RTLD_NOW | RTLD_GLOBAL);

Does anyone have any ideas with what might be wrong?

-- 
Aaron Patterson
http://tenderlovemaking.com/


More information about the Ruby mailing list