Affirmative: I can dynamically link to .dylib libraries with FreePascal by either using the {$linklib} directive, or by passing the name of the library to the linker with the -k option (example: fpc -k"-framework Carbon" test.pas).
Here is in example just for fun of creating a .dylib in C, and then linking to it in Pascal and calling a function. (I'm using Mac OS X 10.3, by the way)
/* This file is called libtest.c */
int test()
{
return 25;
}
/* EOF */
---
{This file is called dylibtest.pas}
program dylibtest;
{$linklib test} {link to our .dylib}
Function test : longint; cdecl; external;
begin
writeln (test);
end.
{EOF}
---
And now compile the c file to a .dylib:
Install the library to /usr/local/lib, then compile the pascal source:cris$ gcc -dynamiclib -o libtest.dylib libtest.c -install_name /usr/local/lib/libtest.dylib
Then run the brand new Mach-O, dynamically linked executable:cris$ fpc dylibtest.pas
And we get 25 printed on the screen just like we should!cris$ ./dylibtest
25
So that's a good sign at least, though simple. I don't know very much about linking and the complications that can arise... I'm downloading JEDI-SDL now, and hope I can get that working
Bookmarks