From: David Craine Date: 2005-01-04T04:44:32+09:00 Subject: Re: Ruby Extensions using OS X Frameworks --Apple-Mail-2--227269321 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed Thanks for the help. I've actually used the -framework option to specify the AddressBook framework, and I'm able to compile, however, when I try to use the extension in a test script I get the following errors: objc: failed objc_getClass(NSObject) for ABAllGroup->isa->isa objc: please link appropriate classes in your program Trace/BPT trap Here is the output generated by the make file: gcc -fno-common -g -O2 -pipe -I. -I/usr/local/lib/ruby/1.8/powerpc-darwin -I/usr/local/lib/ruby/1.8/powerpc-darwin -I. -c RubyABWrapper.c cc -dynamic -bundle -undefined suppress -flat_namespace -framework AddressBook -framework Carbon -L"/usr/local/lib" -o AddressBook.bundle RubyABWrapper.o -ldl -lobjc ld: warning -prebind has no effect with -bundle I'm specifying both the AddressBook framework and the Carbon Framework. The hangup appears to be in locating the library that has the NSObject, which is somewhat confusing to me because my extension is built to use the C API for the AddressBook and not the Objective-C API. Below is the code for the extension (it's short because I'm just trying to test it out right now): #include "ruby.h" #include #include VALUE abWrapper; ABAddressBookRef sharedABRef; static VALUE t_init(VALUE self) { //add other initialization code here sharedABRef= ABGetSharedAddressBook(); return self; } static VALUE t_getMe(VALUE self) { ABPersonRef personRef; personRef = ABGetMe(sharedABRef); } void Init_RubyABWrapper() { abWrapper = rb_define_class("RubyABWrapper", rb_cObject); rb_define_method(abWrapper, "initialize", t_init, 0); rb_define_method(abWrapper, "getMe", t_getMe, 0); } I've created a simple test script that looks like this: require 'AddressBook' t = RubyABWrapper.new t.getMe The objc: failed objc_getClass(NSObject) for ABAllGroup->isa->isa error seems to occur when the AddressBook extension is loaded since I can comment out the remaining lines of the script and the error still occurs. Again, any help/insights would be greatly appreciated. Dave C. On Jan 3, 2005, at 7:09 AM, Michal 'hramrach' Suchanek wrote: > On Thu, Dec 23, 2004 at 12:06:04AM +0900, David Craine wrote: >> I'm trying to write a ruby extension which accesses the >> AddressBook.framework on OS X. I can get the extension to compile but >> get undefined symbol errors for each of the AddressBook APIs when I >> load the extension. It's pretty clear that it's not able to find the >> AddressBook library module, but I'm not quite sure how to tell it >> where >> to look. Anyone have any experience with accessing OS X frameworks in >> this way? > > Generally you need to link in the framework with some flag (probably > -framework or -Wl,-framework -Wl,) during link. > Since LDFLAGS are not supported you should put this to DLDFLAGS. > > You can try to build the extension with the ruby from fink which does > not suppress undefined symbols and would not link an extension without > the required libraries. > > HTH > > Michal Suchanek > > --Apple-Mail-2--227269321--