[Ruby] Native extensions on OS X

Eric Hodel drbrain at segment7.net
Mon Jul 9 08:57:07 PDT 2007


On Jul 8, 2007, at 19:21, Aaron Patterson wrote:

> 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?

Is it static?  I always get that wrong.

nm lollame.bundle | grep -i ' t '

Big T is dynamically linkable.  Little t is not.

--
Poor workers blame their tools. Good workers build better tools. The
best workers get their tools to do the work for them. -- Syndicate Wars




More information about the Ruby mailing list