Errors in include "CFURL.h"

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

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 H. [email protected] 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 ???

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

Referenced from: ./osx/ralias/raliasfile.bundle
-flat_namespace -undefined suppress -read_only_relocs suppress ???
Try linking against the framework using the -framework flag.

$LDFLAGS << " -framework CoreFoundation".

– Daniel

Une bévue [email protected] 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.

Daniel H. [email protected] 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);

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

What is the output from the printf statement?

Oh wait, never-mind, it is there.

– Daniel

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 H. [email protected] 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);