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

U

Une bévue

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

Luc Heinrich

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

CF =3D CoreFoundation !=3D Carbon.

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

--=20
Luc Heinrich - (e-mail address removed) - http://www.honk-honk.com
 
U

Une bévue

Luc Heinrich said:
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 ???
 
U

Une bévue

Une bévue said:
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.
 
D

Daniel Harple

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
 
U

Une bévue

Daniel Harple said:
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);
 
D

Daniel Harple

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

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

What is the output from the printf statement?

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

-- Daniel
 
U

Une bévue

Daniel Harple said:
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);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,209
Messages
2,571,088
Members
47,687
Latest member
IngridXxj

Latest Threads

Top