[fpc-devel] Dynamically Loading Libraries

Marco van de Voort marcov at stack.nl
Wed Nov 11 11:54:30 CET 2009

In our previous episode, Jeppe Johansen said:
> >>     procedure proc; external name 'proc';
> >> denotes a static linked function.
> >>     
> >
> > This syntax is not possible. The external 'xxx' name 'proc' is there for a reason,
> > for systems with multiple linker namespaces. Moreover there is already an
> > enormous codebase that uses this.
> >   
> I don't know if I'm making a fool of myself, but what systems? Skimming 
> the sources, I couldn't find any mention of it in the ELF writers. An 
> external symbol will simply be linked to the first occurrence of a 
> matching symbol in the first shared or static object(unless there's some 
> name mangling going on that I didn't spot). The COFF writer already does 
> it the way I suggested.

Windows, Darwin, and afaik Solaris. The ELF writers are probably not updated
for Solaris yet.

> >> This is ofcourse a solution that would require modification of the 
> >> compiler, but I think in the long run that it'll make alot of things 
> >> more comprehensible
> >
> > I don't. I think this dynamically loading of headers has already gone to
> > far. It is a good workaround for a few headers that are versionwise a
> > disaster, like MySQL, but universally, it doesn't solve problems.
> >   
> In principle, doing it this way would make cross compiling to an ELF 
> platform with dynamic linking easier, once the internal ELF linker is 
> made. 

While partially true, this is a brute force approach. Having a few simple
map files (that can be generated on target from the libs) over which files
contain which symbols might help too. 

More information about the fpc-devel mailing list