The problem is that you are using an MS static library which references a symbol (_chkstk) that is defined in the MS C library but not in the MinGW one. The version in ntdll.dll is presumably equivalent but when building with MSVC I expect that it would be using a different version in a static library. However, the version of libntdll.a that I have does not define _chkstk, so this is why adding "-lntdll" didn't work for you. You can generate an import library for ntdll.dll that has this symbol, as explained here (Google found this easily):
P.S. don't use --enable-stdcall-fixup
----- Original Message -----
From: Paul G.
Sent: Sunday, June 08, 2003 6:15 AM
Subject: [Mingw-msys] "ld"

Hi folks,

  I have hit a "hitch" in an autoconfisticate process which is showing "_chkstk" as undefined.

  I am using Msys Autoconf utilities.
  "msysdvlpr" has not been invoked, so I am actually building this particular app using Msys hosted Mingw.
  GCC being used:  3.2.3
  Msys 1.09-2003-06.05-1 (Distro/Snapshot).
  ld: v2.13

  config.log output (note:  I have added "\" for the sake of clarity -- actual config.log output
is one big long line):

ld.exe -Bdynamic -o conftest.exe \
d:/msys/1.0/mingw/bin/../lib/gcc-lib/mingw32/3.2.3/../../../crt2.o \
d:/msys/1.0/mingw/bin/../lib/gcc-lib/mingw32/3.2.3/crtbegin.o \
-Ld:/mysql/lib \
-Ld:/msys/1.0/mingw/bin/../lib/gcc-lib/mingw32/3.2.3 \
-Ld:/msys/1.0/mingw/bin/../lib/gcc-lib \
-Ld:/msys/1.0/mingw/CSMING~1/lib \
-Ld:/msys/1.0/mingw/bin/../lib/gcc-lib/mingw32/3.2.3/../../../../mingw32/lib \
-L/mingw/lib/gcc-lib/mingw32/3.2.3/../../../../mingw32/lib \
-Ld:/msys/1.0/mingw/bin/../lib/gcc-lib/mingw32/3.2.3/../../.. \
-L/mingw/lib/gcc-lib/mingw32/3.2.3/../../.. \
-lz d:\TEMP/cckhaaaa.o \
-lmysqlclient -lwsock32 -lntdll -lmingw32 -lgcc -lmoldname -lmingwex \
-lmsvcrt -luser32 -lkernel32 -ladvapi32 -lshell32 -lmingw32 -lgcc -lmoldname \
-lmingwex -lmsvcrt \
d:/mysql/lib\mysqlclient.lib(./release/my_messnc.obj)(.text+0x5a):D:\mysql-4.0.12\my: variable '_iob' can't be auto-imported. Please read the documentation for ld's -- enable-auto-import for details.
d:/mysql/lib\mysqlclient.lib(./release/default.obj)(.text+0x6):D:\mysql-4.0.12\my: undefined reference to `_chkstk'

--- end of config.log excerpt

My analysis so far:

  The "...'-iob' can't be auto-imported..." bit, according to the documentation for mysql, is something that can be "safely ignored".

  Yes, according to the "ld" docs, "..this (type of) message occurs when some (sub)expression accesses an address ultimately given by the sum of two constants (Win32 import tables only allow one)."

  The library which is generating this "undefined reference to '_chkstk'..." is an MS static lib (as noted above), which, aside from the few "...'_iob'.." messages, is being auto-imported by "ld" just fine (mysqlclient.lib).

  A quick check of where "_chkstk" is being defined shows that "_chkstk" is defined in one place as "_chkstk" (ntdll.dll), and in another (libgcc.a) as "___chkstk".

  Initially, "___chkstk" (defined in libgcc.a) appears but is not being linked to "_chkstk" (defined in libntdll.a).

  Bottom line, since both ntdll (libntdll.a) and gcc (libgcc.a) are members of (read "are being referenced by") the "ld" command line (...-lntdll ... -lgcc), it doesn't make a lot of sense as to "why" "_chkstk" remains undefined.

    At this point, I am thinking that maybe I need to define --enable-stdcall-fixup as an "ld" option.

  Comments? Ideas? Feedback?


    Paul G.