[fpc-pascal] [semi-off-topic] some C questions arising while using h2pas

Jonas Maebe jonas.maebe at elis.ugent.be
Fri Jul 15 13:54:38 CEST 2011

On 15 Jul 2011, at 13:43, Bernd wrote:

> To get used to this entire thing I am beginning with something much
> more simple, I will try to get some sha hashing functions from openssl
> imported (I will also need them, so it would not hurt to start with
> them).

FPC comes with translated openssl headers, so other than for learning purposes you shouldn't have to do this.

>  Now the question
> (and I am intentionally asking this on a Pascal list and not a C list
> to get an answer that better fits into my Pascal brain) how would the
> C compiler or linker know from where exactly to import these
> functions?

On Unix-like systems, at static link time (i.e., at the end of compiling the program), the linker searches all libraries specified on the command line for the used symbols. If a symbol is not found, you get an error. Furthermore, at run time the dynamic linker again will search for those same symbols. Depending on the operating system and the dynamic linker settings, it will only search for those symbols in certain libraries or again in any library that's in the (dynamic) library path. The binary generally does not contain information about from which library a particular symbol comes (exceptions are Windows, and at least also Mac OS X to some extent).

http://blogs.embarcadero.com/eboling/2010/02/16/5656/ contains a fairly good overview of the symbol binding strategies on different platforms.


More information about the fpc-pascal mailing list