U
Une bévue
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-
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 .
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-
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 .