FFI & MacOS X
diegobt at hotmail.com
Thu Jun 10 05:28:29 UTC 2004
Hi, I am new to mac and I can't get FFI to work in MacOSX.
I am using the 3.6 carbon-classic vm. Im still a bit confused with
Mach-O. I was used to good'ole elf and dlls.
In order to test I wrote a small example and compiled it both .bundle
and .dylib following apple examples. I get the message "cannot find function
address".I can use them from C via the NS way (bundle) and linking to a dylib,
but cant get sq to find the symbols :(
THIS IS FOR THE DYLIB:
this would be answer.c:
this would be deep.c:
answer = get_answer();
printf("the answer is %d\n", answer);
this would be the Makefile:
cc -fno-common -c answer.c
cc -dynamiclib -install_name libanswer.dylib \
-o libanswer.dylib answer.o
cc -fno-common -c deep.c
deep: deep.o libanswer.dylib
$(LD) -o deep deep.o -L. -lanswer
FOR THE BUNDLE:
cc -flat_namespace -bundle -undefined supress \ -o libanswer.bundle
I then use NSLookupSymbol() and NSAddressOfSymbol() functions (after
loading the file with other NS commands) in the deep.c file.
I can't get this to work:
<cdecl: short 'get_answer' (void) module:'libanswer'>
Question: which type of library does FFI use? .bundle or dylibs or both?
Where does it look for it? putting it in the vm dir doesn't work, there
is no ldconfig (ahhhh!)./system/library/frameworks doesent work either (copying my lib into it I
The thing is I need to use ODBC with squeak in my mac (Diego Gomez
Deck's code I mean). In linux I simply symlinked libiodbc to the vm's directory. In OSX I got
Any help would be REALLY apreciated!
thx in advance!
More information about the Squeak-dev