[fpc-pascal] using static linking of dylib in mac 10.5

Jonas Maebe jonas.maebe at elis.ugent.be
Mon Oct 20 10:50:13 CEST 2008


On 19 Oct 2008, at 20:54, Guru Kathiresan wrote:

> I'm not able to do a static link of a dylib (with the latest lazarus  
> + fpc
> build).
>
> I'm using the following code:
>
> function MyDyLibFunction: int; cdecl; external 'mylib.dylib';
> begin
>  MyDyLibFunction;
> end;
>
> If I use the LoadLibrary function to load the 'mylib.dylib' I'm  
> getting a
> valid TLibHandle. Also the nm list MyDyLibFunction function (with _  
> prefix)
> in the library.
>
> Can anyone give a pointer on how to make fpc statically link my shared
> library in mac osx?

You cannot statically link a dynamic library. I guess you want to  
dynamically link it, but at compile time rather than manually at  
runtime using LoadLibrary(). To do so, add {$linkib mylib} to the  
source. This will also work on other platforms.


Jonas



More information about the fpc-pascal mailing list