How to solve ——-undefined reference to `__chkstk_ms’——-on mingw

Here’s an authoritative answer, from a MinGW project administrator.

Your problem arises because you continue to use an obsolete, (no longer maintained; no longer supported), version of GCC. Current versions of mingwrt are compiled using GCC-4.x, (I used GCC-4.8.2 for mingwrt-3.21 and its descendants), and this introduces the dependencies on __chkstk_ms, (which is provided by libgcc — a GCC-4.x specific library, which is incompatible with GCC-3.x).

FWIW, I can reproduce your issue if I install a GCC-4.8.2 built mingwrt-3.21.1 into a GCC-3.4.5 installation. By the same token, I can also successfully use mingwrt-3.21.1 with GCC-3.4.5, if I build it with that same version of GCC.

Thus, for an authoritative answer: if you must continue to use an obsolete GCC version, you need to be prepared to rebuild all associated libraries, using that same obsolete compiler.

Leave a Comment