[fpc-pascal] HMAC_SHA1 and FPC

Anthony Walter sysrpl at gmail.com
Tue Mar 26 14:05:16 CET 2013


On Tue, Mar 26, 2013 at 5:57 AM, Marcos Douglas <md at delfire.net> wrote:

> Hi,
> Is possible to make that only using Windows for any lib?
>
> Best regards,
> Marcos Douglas


Marcos,

Are you asking, "Is it possible to build any static lib for Windows and
link it to a free pascal project"?

No, not all the time. Libraries may depend on systems function on one
platform which are not available on another.

But, many times you can if the library can compile with mingw64. When this
is the case you build a C project using mingw64, copy the lib files to a
directory free pascal is using (see environment settings in lazarus), list
the functions in a unit, then put {$linklib youlibname.a} in the
implementation section. You may need a few {$ifdef}s for your different
platforms.

The benefit of this is that you can easily incorporate (much more easily
rewriting) *complex* functionality into your free pascal projects knowing
what you are reusing is probably faster, has more features, is more robust,
and better tested than a implementation of X that someone reinvented again
for free pascal.

Sometimes though you might be are better off using dynamic linking (so, dll
on windows) if you know the OS is going to provide features. Examples are
msxml.dll vs libxml2.so, gdiplus.dll vs libcario.so, ect. Of course in
these cases what probably you need to do is write some lite wrappers, since
the apis vary in form (but not function). In those cases I typically use
interfaces...

IXmlDocument, IXmlNode // for pasring or building Xml
ICanvas, IBrush // for drawing

and then

function CreateXmlDocument: IXmlDocument; {$fidef}s
function CreateCanvas: ICanvas; {$fidef}s
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20130326/677ba55b/attachment.html>


More information about the fpc-pascal mailing list