[fpc-pascal]mysql package under WinNT

Bernhard Steffen bernhard.steffen at gmx.net
Sun Mar 11 15:02:22 CET 2001

I tried using the mysql package under WinNT and got some weird errors.
Here's what I found out to solve the problem:

I couldn't get "make" to run - it always complained it cannot find
/bin/sh, although I had copied sh.exe to /bin on every single drive I

So I tried compiling the demo program testdb.pp by manually calling ppc.
Compiling was fine, but linking always failed "could not find
-lmysqlclient". I patched "link.res" and changed the INPUT() section:
changed "-lmysqlclient", "-lm", "-lc" to just "mysqlclient.lib" and
called ldw directly - which works fine, but seems a little bit awkward
to me.

So I investigated further and found out a slight error in mysql_com.pp:
There is a section declaring the required libraries:

  {$linklib mysqlclient}
  {$linklib m}
  {$linklib c}

This may work under LINUX (haven't tried), but doesn't under WinNT.
Changing it to the following lines makes it work perfectly under WinNT
as well:

  {$ifdef win32}
    {$linklib mysqlclient.lib}
    {$linklib mysqlclient}
    {$linklib m}
    {$linklib c}

(Leaving out the file extension ".lib" brakes linking for WinNT again.)

Maybe "make" takes care of this problem already - I don't know, since
make does not work on my computer yet. On the other hand, if you apply
this patch, you can compile it directly (mysqlclient.lib needs to be in
a path defined by "-Fl" option, "libmysql.dll" needs to be in path at
runtime of your program). Maybe someone can include this into the
official distribution?

Bernhard Steffen

bernhard.steffen at gmx.net

More information about the fpc-pascal mailing list