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

ik idokan at gmail.com
Fri Jul 15 14:00:04 CEST 2011


On Fri, Jul 15, 2011 at 14:43, Bernd <prof7bit at googlemail.com> wrote:

> I am just trying to convert some openssl headers to Pascal (I know
> that there is an openssl unit in the fpc packages but it is missing
> the ECDSA functions which I will need later and which is main reason I
> am starting to look into openssl).
>
> 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).
>
> I am referring to the header file /usr/include/openssl/sha.h (pastebin
> here: http://pastebin.com/dS8DY2z9 )
>
> After appyling h2pas i have the following: http://pastebin.com/v3S3vtFR
>
> If I want to import functions in Pascal I would either declare them
> external and explicitly tell it the name of the library binary (this
> seems straightforward to me, I see no problems with this) or I load it
> dynamically at runtime and then ask for the addresses of the functions
> that I need and assign them to procedure variables (I have also done
> this already on some occasions and it is equally easy to understand
> and also raises no questions).
>
> I am confused about something else:
>
> When looking at the .h file and also when looking at the generated .pp
> file it seems that nowhere in the header there was any information
> about which .so (or .dll) to load or link against. It created empty
> bodies with { you must implement this function }. 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? Where is this information, how are these C folks doing
> these things, what kind of magic have they going on?
>

The information is located under /usrlib/pkgconfig/openssl.pc

It tells to the configure script how to generate the Makefile and how to
link stuff. It just a gcc syntax that is pasted back to the Makefile.

I wrote a tool once (in Bash) that allow you properly search for a function
inside an so to see who have it.
If you wish, you can find it here:
http://code.google.com/p/pasxlibbind/source/browse/trunk/find_function.sh



>
> confused,
> Bernd
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>


Ido
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20110715/695c6d43/attachment.html>


More information about the fpc-pascal mailing list