# Writing a C ext to Ruby and dyld: NSLinkModule() error

**URL:** <https://www.ruby-forum.com/t/writing-a-c-ext-to-ruby-and-dyld-nslinkmodule-error/101834>\
**Category:** Ruby\
**Created:** [August 8, 2006, 8:31am UTC](https://www.ruby-forum.com/t/writing-a-c-ext-to-ruby-and-dyld-nslinkmodule-error/101834 "2006-08-08T08:31:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [August 8, 2006, 8:31am UTC](https://www.ruby-forum.com/t/writing-a-c-ext-to-ruby-and-dyld-nslinkmodule-error/101834/1 "2006-08-08T08:31:59Z")

</div>

iu’ev to write a C ext to Ruby (i’ve allready an ObjC one) and, for that  
purpose i familiarise myself with C and Ruby ext.

i’ve done the test in “How to create a Ruby extension in C in under 5  
minutes”  
\<[http://www.rubyinside.com/how-to-create-a-ruby-extension-in-c-in-under-](http://www.rubyinside.com/how-to-create-a-ruby-extension-in-c-in-under-)  
5-minutes-100.html\> and have foolowed afterwards “The Pragmatic  
Programmer’s Guide \>\> Extending Ruby” i’ve written \*.c and \*.h as it is  
in this page, my extconf.rb being as simple as :

— extconf.rb --------------------------------------------------------  
require ‘mkmf’

# Give it a name

#extension\_name = ‘cdjukebox’

# The destination

dir\_config(‘cdjukebox’)

# Do the work

## create\_makefile(“CDJukebox”)

i get the “CDJukebox.bundle” and try it using this code :

— jukebox.rb --------------------------------------------------------  
require ‘Jukebox/cdjukebox’

## p = CDPlayer.new(1) puts “Unit is #{p.unit}” p.seek(3, 16) {|x| puts “#{x}% done” } puts “Avg. time was #{p.seekTime} seconds”

if i print out the $LOAD\_PATH i get :  
["/Applications/TextMate/TextMate.app/Contents/SharedSupport/Support/lib  
", “/opt/local/lib/ruby/site\_ruby/1.8”,  
“/opt/local/lib/ruby/site\_ruby/1.8/powerpc-darwin8.7.0”,  
“/opt/local/lib/ruby/site\_ruby”, “/opt/local/lib/ruby/vendor\_ruby/1.8”,  
“/opt/local/lib/ruby/vendor\_ruby/1.8/powerpc-darwin8.7.0”,  
“/opt/local/lib/ruby/vendor\_ruby”, “/opt/local/lib/ruby/1.8”,  
“/opt/local/lib/ruby/1.8/powerpc-darwin8.7.0”, “.”]

then the dot “.” is here.

here is the error i get :  
dyld: NSLinkModule() error  
dyld: Symbol not found: \_CDPlayerSeek  
Referenced from: ./Jukebox/cdjukebox.bundle  
Expected in: flat namespace

i think the prob come with the MakeFile and then from extconf.rb too  
simplistic…

i’ve seen after googleing that some args to the compiler might be  
missing, then i’ve tried adding :

-read\_only\_relocs suppress to the line "LDSHARED = " in MakeFile

or :  
-framework IOKit -framework CoreFoundation -framework Carbon

to the line “LIBS” in the same file

and try to setup “LDFLAGS” to “-Wl,-read\_only\_relocs,warning” before  
running make.

none of those get a successfull run .
