MinGW C++11 Issues

I'm trying out MinGW (MinGW32 from mingw.org) and there seems to be a strange issue when telling the compiler to use C++11. For example the following program:

1
2
3
4
5
6
7
#include <iostream>

int main()
{
   std::cout << " Hello World! " << std::endl;
   return 0;
}


when compiled with the -std=c++11 flag I get errors like this:

$ g++ hello_world.cpp -std=c++11
In file included from c:\mingw\include\wchar.h:208:0,
                 from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:44,
                 from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\postypes.h:40,
                 from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iosfwd:40,
                 from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:38,
                 from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
                 from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
                 from hello_world.cpp:2:
c:\mingw\include\sys/stat.h:173:14: error: '_dev_t' does not name a type
 struct _stat __struct_stat_defined( _off_t, time_t );


And about another 200 lines of similar error messages.

However, when I compile with the -std=gnu++11 flag it works fine (as suggested in this stackoverflow post http://stackoverflow.com/questions/38538924/g-updated-on-mingw-gets-massive-error-messages ).

Has anyone else come across this issue or a better way to get around it than using -std=gnu++11 ?

GCC version is reported as:

$ g++ -v
Using built-in specs.
COLLECT_GCC=C:\MinGW\bin\g++.exe
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/5.3.0/lto-wrapper.exe
Target: mingw32
Configured with: ../src/gcc-5.3.0/configure --build=x86_64-pc-linux-gnu --host=mingw32 --prefix=/mingw --disable-win32-registry --target=mingw32 --with-arch=i586 --enable-languages=c,c++,objc,obj-c++,fortran,ada --enable-static --enable-shared --enable-threads=posix --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --enable-libstdcxx-debug --with-tune=generic --enable-libgomp --disable-libvtv --enable-nls
Thread model: posix
gcc version 5.3.0 (GCC)

This is suspicious:
--build=x86_64-pc-linux-gnu


I'd suggest you to get MinGW from somebody else, like here: https://nuwen.net/mingw.html
Last edited on
Hmm, you're probably right - that --build option does seem a bit weird (though I don't know what the correct value should be).

I wasn't sure what was the "best" source to install from (i.e. mingw or mingw-w64). Seeing as how that guy's using w64 for his distro (& has a more up-to-date version of gcc), I might start over with his one.

Thanks
Topic archived. No new replies allowed.