title: How to compile C++ using MinGW on Windows?
body: <p>I'm getting the following error</p>
  <p><code>cannot find -lstdc++</code></p>
  <p><code>collect2.exe: error: ld returned 1 exit status</code></p>
  <p>it's a simple Hello World program.</p>
  <p><code>g++ version</code> returns</p>
  <pre class="lang-none prettyprint-override"><code>g++ (MinGW.org GCC Build-2) 9.2.0
  </code></pre>
  <p><code>g++ -v &lt;filename.cpp&gt;</code> returns</p>
  <pre class="lang-none prettyprint-override"><code>Using built-in specs.
  COLLECT_GCC=g++
  COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/9.2.0/lto-wrapper.exe
  Target: mingw32
  Configured with: ../src/gcc-9.2.0/configure --build=x86_64-pc-linux-gnu --host=mingw32 --target=mingw32 --disable-win32-registry --with-arch=i586 --with-tune=generic --enable-static --enable-shared --enable-threads --enable-languages=c,c++,objc,obj-c++,fortran,ada --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --enable-libgomp --disable-libvtv --with-libiconv-prefix=/mingw --with-libintl-prefix=/mingw --enable-libstdcxx-debug --disable-build-format-warnings --prefix=/mingw --with-gmp=/mingw --with-mpfr=/mingw --with-mpc=/mingw --with-isl=/mingw --enable-nls --with-pkgversion='MinGW.org GCC Build-2'
  Thread model: win32
  gcc version 9.2.0 (MinGW.org GCC Build-2)
  COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mtune=generic' '-march=i586'
  c:/mingw/bin/../libexec/gcc/mingw32/9.2.0/cc1plus.exe -quiet -v -iprefix c:\mingw\bin\../lib/gcc/mingw32/9.2.0/ hw.cpp -quiet -dumpbase hw.cpp -mtune=generic -march=i586 -auxbase hw -version -o C:\Users\move78~1\AppData\Local\Temp\ccQus9Kp.s
  GNU C++14 (MinGW.org GCC Build-2) version 9.2.0 (mingw32)
  compiled by GNU C version 9.2.0, GMP version 6.1.2, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.21-GMP
  
  GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
  ignoring nonexistent directory &quot;c:\mingw\bin\../lib/gcc/mingw32/9.2.0/../../../../mingw32/include&quot;
  ignoring duplicate directory &quot;c:/mingw/lib/gcc/../../lib/gcc/mingw32/9.2.0/include/c++&quot;
  ignoring duplicate directory &quot;c:/mingw/lib/gcc/../../lib/gcc/mingw32/9.2.0/include/c++/mingw32&quot;
  ignoring duplicate directory &quot;c:/mingw/lib/gcc/../../lib/gcc/mingw32/9.2.0/include/c++/backward&quot;
  ignoring duplicate directory &quot;c:/mingw/lib/gcc/../../lib/gcc/mingw32/9.2.0/include&quot;
  ignoring duplicate directory &quot;/mingw/lib/gcc/mingw32/9.2.0/../../../../include&quot;
  ignoring duplicate directory &quot;c:/mingw/lib/gcc/../../include&quot;
  ignoring duplicate directory &quot;c:/mingw/lib/gcc/../../lib/gcc/mingw32/9.2.0/include-fixed&quot;
  ignoring nonexistent directory &quot;c:/mingw/lib/gcc/../../lib/gcc/mingw32/9.2.0/../../../../mingw32/include&quot;
  ignoring duplicate directory &quot;/mingw/include&quot;
  #include &quot;...&quot; search starts here:
  #include &lt;...&gt; search starts here:
  c:\mingw\bin\../lib/gcc/mingw32/9.2.0/include/c++
  c:\mingw\bin\../lib/gcc/mingw32/9.2.0/include/c++/mingw32
  c:\mingw\bin\../lib/gcc/mingw32/9.2.0/include/c++/backward
  c:\mingw\bin\../lib/gcc/mingw32/9.2.0/include
  c:\mingw\bin\../lib/gcc/mingw32/9.2.0/../../../../include
  c:\mingw\bin\../lib/gcc/mingw32/9.2.0/include-fixed
  End of search list.
  GNU C++14 (MinGW.org GCC Build-2) version 9.2.0 (mingw32)
  compiled by GNU C version 9.2.0, GMP version 6.1.2, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.21-GMP
  
  GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
  Compiler executable checksum: cb31672760a9c1b42d1ddb86616116cd
  COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mtune=generic' '-march=i586'
  c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/as.exe -v -o C:\Users\move78~1\AppData\Local\Temp\cctjBjko.o C:\Users\move78~1\AppData\Local\Temp\ccQus9Kp.s
  GNU assembler version 2.32 (mingw32) using BFD version (GNU Binutils) 2.32
  COMPILER_PATH=c:/mingw/bin/../libexec/gcc/mingw32/9.2.0/;c:/mingw/bin/../libexec/gcc/;c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/
  LIBRARY_PATH=c:/mingw/bin/../lib/gcc/mingw32/9.2.0/;c:/mingw/bin/../lib/gcc/;c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/lib/;c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../
  COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mtune=generic' '-march=i586'
  c:/mingw/bin/../libexec/gcc/mingw32/9.2.0/collect2.exe -plugin c:/mingw/bin/../libexec/gcc/mingw32/9.2.0/liblto_plugin-0.dll -plugin-opt=c:/mingw/bin/../libexec/gcc/mingw32/9.2.0/lto-wrapper.exe -plugin-opt=-fresolution=C:\Users\move78~1\AppData\Local\Temp\ccxROszG.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmsvcrt -Bdynamic -u ___register_frame_info -u ___deregister_frame_info c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../crt2.o c:/mingw/bin/../lib/gcc/mingw32/9.2.0/crtbegin.o -Lc:/mingw/bin/../lib/gcc/mingw32/9.2.0 -Lc:/mingw/bin/../lib/gcc -Lc:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/lib -Lc:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../.. C:\Users\move78~1\AppData\Local\Temp\cctjBjko.o -lstdc++ -lmingw32 -lmingwex -lmingw32 -lmingwex -lgcc_s -lgcc -lmoldname -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lmingwex -lmingw32 -lmingwex -lgcc_s -lgcc -lmoldname -lmsvcrt c:/mingw/bin/../lib/gcc/mingw32/9.2.0/crtend.o
  c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: cannot find -lstdc++
  collect2.exe: error: ld returned 1 exit status
  </code></pre>