title: How to solve -------undefined reference to `__chkstk_ms'-------on mingw
body: <p>I have just install gcc and g++ on mingw.
  I wrote a very simple "hello world" program to test if the g++ compiler worked.
  Code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  int main()
  {
  cout &lt;&lt; "hello world" &lt;&lt; endl;
  return 0;
  }
  </code></pre>
  
  <p>Compile:</p>
  
  <pre><code>g++ Test.cpp
  </code></pre>
  
  <p>And then some errors appear:</p>
  
  <pre><code>D:/MinGW[Finished in 0.6s with exit code    1]/bin/../lib/gcc/mingw32/3.4.5/../../../../mingw32/lib/crt2.o: In function `_mingw_setargv':
  D:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../mingw32/lib/libmingwex.a(glob.o): In function `glob_match':
  i:\p\giaw\src\pkg\mingwrt-4.0-1-mingw32-src\bld/../mingwrt-4.0.0-1-mingw32-src/src/libcrt/misc/glob.c:733: undefined reference to `__chkstk_ms'
  D:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../mingw32/lib/libmingwex.a(glob.o): In function `glob_strdup':
  i:\p\giaw\src\pkg\mingwrt-4.0-1-mingw32-src\bld/../mingwrt-4.0.0-1-mingw32-src/src/libcrt/misc/glob.c:85: undefined reference to `__chkstk_ms'
  D:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../mingw32/lib/libmingwex.a(glob.o): In function `glob_match':
  i:\p\giaw\src\pkg\mingwrt-4.0-1-mingw32-src\bld/../mingwrt-4.0.0-1-mingw32-src/src/libcrt/misc/glob.c:841: undefined reference to `__chkstk_ms'
  D:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../mingw32/lib/libmingwex.a(glob.o): In function `glob_strdup':
  i:\p\giaw\src\pkg\mingwrt-4.0-1-mingw32-src\bld/../mingwrt-4.0.0-1-mingw32-src/src/libcrt/misc/glob.c:85: undefined reference to `__chkstk_ms'
  D:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../mingw32/lib/libmingwex.a(glob.o):i:\p\giaw\src\pkg\mingwrt-4.0-1-mingw32-src\bld/../mingwrt-4.0.0-1-mingw32-src/src/libcrt/misc/glob.c:85: more undefined references to `__chkstk_ms' follow
  collect2: ld returned 1 exit status
  </code></pre>