--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 <AddressBook/ABAddressBookC.h>
#include <AddressBook/ABGlobalsC.h>
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.
Generally you need to link in the framework with some flag (probably
-framework <framework> or -Wl,-framework -Wl,<farmework>) 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--