[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

[MacOS X Ruby-ext] errors in include "CFURL.h"

pere.noel

8/14/2006 6:14:00 AM


now, my skeleton is working (thanks to ) i want to add Carbon function
into my c file.

i've only added :

#include "/Developer/Headers/FlatCarbon/CFURL.h"

and :

CFURLRef url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
(CFStringRef)_fullAliasPath, kCFURLPOSIXPathStyle, NO);

into my "RAliasFile.c"

and i get number of errors within "CFURL.h" and related, i suppose this
is a syntax prob then, i have to convert "CFURL.h" to be C-Ruby
compatible ???

--
une bévue
8 Answers

Luc Heinrich

8/14/2006 8:33:00 AM

0

On 14 août 06, at 08:15, Une bévue wrote:

> #include "/Developer/Headers/FlatCarbon/CFURL.h"

CF = CoreFoundation != Carbon.

You simply need #include <CFUrl.h> and then instruct gcc to look for
it in
/System/Library/Frameworks/CoreFoundation.framework/Headers/

--
Luc Heinrich - luc@honk-honk.com - http://www.hon...



pere.noel

8/14/2006 9:11:00 AM

0

Luc Heinrich <luc@honk-honk.com> wrote:

>
> CF = CoreFoundation != Carbon.
>
> You simply need #include <CFUrl.h> and then instruct gcc to look for
> it in
> /System/Library/Frameworks/CoreFoundation.framework/Headers/

oK thanxs, i've done that :

$CFLAGS << " -I
/System/Library/Frameworks/CoreFoundation.framework/Headers "

in my "extconf.rb" where mkmf is included.

however i get (at run time) :
dyld: NSLinkModule() error
dyld: Symbol not found: _CFURLCreateWithFileSystemPath
Referenced from: ./osx/ralias/raliasfile.bundle
Expected in: flat namespace

does i need to change another flag, for example :
LDFLAGS ??

should have :
-read_only_relocs suppress

giving for the whole :

-flat_namespace -undefined suppress -read_only_relocs suppress ???
--
une bévue

pere.noel

8/14/2006 9:20:00 AM

0

Une bévue <pere.noel@laponie.com.invalid> wrote:

> does i need to change another flag, for example :
> LDFLAGS ??

i've allready try :
LDFLAGS="-Wl,-read_only_relocs,warning"

in my "extconf.b" raising the same prob.

--
une bévue

Daniel Harple

8/14/2006 1:49:00 PM

0


On Aug 14, 2006, at 5:15 AM, Une bévue wrote:

> oK thanxs, i've done that :
>
> $CFLAGS << " -I
> /System/Library/Frameworks/CoreFoundation.framework/Headers "
>
> in my "extconf.rb" where mkmf is included.
>
> however i get (at run time) :
> dyld: NSLinkModule() error
> dyld: Symbol not found: _CFURLCreateWithFileSystemPath
> Referenced from: ./osx/ralias/raliasfile.bundle
> Expected in: flat namespace
>
> does i need to change another flag, for example :
> LDFLAGS ??
>
> should have :
> -read_only_relocs suppress
>
> giving for the whole :
>
> -flat_namespace -undefined suppress -read_only_relocs suppress ???

Try linking against the framework using the -framework flag.

$LDFLAGS << " -framework CoreFoundation".

-- Daniel


pere.noel

8/14/2006 2:18:00 PM

0

Daniel Harple <dharple@generalconsumption.org> wrote:

> Try linking against the framework using the -framework flag.
>
> $LDFLAGS << " -framework CoreFoundation".

fine thanks, it's ok now for the links, however i get a bus error at
runtime :

/Users/yvon/work/Ruby/Native/C/raliasfile_test.rb:8: [BUG] Bus Error
ruby 1.8.4 (2005-12-24) [powerpc-darwin8.7.0]

From C => alias_path :
/Users/yvon/work/Ruby/Native/C/doc/Introduction_ANSI_C_html

the line 8 of raliasfile_test.rb being simply :

a=RAliasFile.new("/Users/yvon/work/Ruby/Native/C/doc/Introduction_ANSI_C
_html")
(just after "require 'osx/ralias/raliasfile'")

and on the C side :

VALUE m_raliasfile_init(VALUE self, VALUE alias_path)
{
printf("From C => alias_path : %s\n", StringValuePtr(alias_path));
rb_iv_set(self, "@alias_path", alias_path);
Boolean NO=(Boolean)Qfalse;
CFURLRef url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
(CFStringRef)alias_path, 0, NO);
if (url != NULL) {
printf("From C => url != NULL\n");
}
return self;
}

from the printf(...) i know the error is certaiinly due to this line :

CFURLRef url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
(CFStringRef)alias_path, 0, NO);




--
une bévue

Daniel Harple

8/14/2006 2:42:00 PM

0

On Aug 14, 2006, at 10:20 AM, Une bévue wrote:

> from the printf(...) i know the error is certaiinly due to this line :
>
> CFURLRef url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
> (CFStringRef)alias_path, 0, NO);

What is the output from the printf statement?

Try (CFStringRef)StringValuePtr(alias_path) or CFSTR(StringValuePtr
(alias_path)).

-- Daniel


Daniel Harple

8/14/2006 2:45:00 PM

0

On Aug 14, 2006, at 10:42 AM, Daniel Harple wrote:

> What is the output from the printf statement?

Oh wait, never-mind, it is there.

-- Daniel


pere.noel

8/14/2006 4:06:00 PM

0

Daniel Harple <dharple@generalconsumption.org> wrote:

> What is the output from the printf statement?

From C => alias_path :
/Users/yvon/work/Ruby/Native/C/doc/Introduction_ANSI_C_html

> Try (CFStringRef)StringValuePtr(alias_path)

still a seg fault :
"-L/opt/local/lib -framework CoreFoundation\ncreating Makefile\n"
"gcc -fno-common -O -pipe -I/opt/local/include -fno-common -pipe
-fno-common -I
/System/Library/Frameworks/CoreFoundation.framework/Headers -I.
-I/opt/local/lib/ruby/1.8/powerpc-darwin8.7.0
-I/opt/local/lib/ruby/1.8/powerpc-darwin8.7.0 -I. -O -pipe
-I/opt/local/include -c RAliasFile.c\ncc -dynamic -bundle -undefined
suppress -flat_namespace -L/opt/local/lib -framework CoreFoundation
-L\"/opt/local/lib\" -o raliasfile.bundle RAliasFile.o -lruby
-lpthread -ldl -lobjc \n"
/Users/yvon/work/Ruby/Native/C/osx/ralias/compil.rb:31: [BUG]
Segmentation fault
ruby 1.8.4 (2005-12-24) [powerpc-darwin8.7.0]

From C => alias_path :
/Users/yvon/work/Ruby/Native/C/doc/Introduction_ANSI_C_html

> or CFSTR(StringValuePtr(alias_path)).

and here i get a parse error (???) :

RAliasFile.c:29: error: parse error before 'rb_string_value_ptr'

the line being :

CFURLRef url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
CFSTR(StringValuePtr(alias_path)), 0, NO);

--
une bévue