[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Ruby Extensions using OS X Frameworks

David Craine

12/22/2004 3:06:00 PM

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?

Dave Craine
InfoEther



5 Answers

Dave Baldwin

12/22/2004 3:48:00 PM

0

You could try adding

$LDFLAGS = '-framework AddressBook'

into you extconf.rb file.

Dave.

On 22 Dec 2004, at 15:06, 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?
>
> Dave Craine
> InfoEther
>
>



Marshall Elfstrand

12/22/2004 4:20:00 PM

0

In case it is of help, RubyCocoa is able to access the Address Book.
See:

http://www.fobj.com/rubycocoa/doc/f...

I haven't tested it myself though.

Marshall


On Dec 22, 2004, at 7:06 AM, 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?
>
> Dave Craine
> InfoEther
>



David Craine

12/31/2004 3:29:00 AM

0

Thanks Dave. That got me past the initial linking error. I am getting
another linking error apparently when it tries to lookup NSObject. I tried
adding "-framework Foundation.framework" to the LDFLAGS setting as well but
that didn't seem to help. Any additional thoughts?

Dave

-----Original Message-----
From: Dave Baldwin [mailto:dave.baldwin@3dlabs.com]
Sent: Wednesday, December 22, 2004 10:48 AM
To: ruby-talk ML
Subject: Re: Ruby Extensions using OS X Frameworks

You could try adding

$LDFLAGS = '-framework AddressBook'

into you extconf.rb file.

Dave.

On 22 Dec 2004, at 15:06, 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?
>
> Dave Craine
> InfoEther
>
>







Michal Suchanek

1/3/2005 12:10:00 PM

0

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


David Craine

1/3/2005 7:45:00 PM

0

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.




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