last day (14 days later) » 

3:01 PM
0
Q: mingw 5 std::this_thread not defined

user3453753Hi any body try to use header support mingw w64? main.cpp: In function 'int main()': main.cpp:9:10: error: 'std::this_thread' has not been declared std::this_thread::sleep_for( dura ); ^ I got above error with following simple test #include <iostream> #include <chrono> #include <thread>...

 
I have mingw64 v4.9.2 and your example compiles and works fine
 
Did you compile with -pthread?
 
I dont know, this is someone builds, see above links
 
I have that exact same version as you do OP.. It's there: i.imgur.com/3Pg24zb.png but it won't compile or work. Some define is probably missing.. 4.9.2 has no problem so it's of course just that specific version.
 
@Brandon your image is missing
@Collin, how to compile mingw gcc from source, that sounds exhaustive work, how long to get this compile whole gcc stack with mingw header support
 
3:01 PM
@user3453753: You should be compiling your application with -pthread, not gcc.
 
not working either, tried g++ main.cpp -std=c++11 -lpthread -o main
I got header std::thread header not defined, -lpthread is just linking process
 
command line c++ -std=c++11 -Wall -pthread bbb.cpp, no warning (well, I've added return 0 as last statement), prints hello, waits, prints waited
gcc version 4.9.2 (x86_64-posix-seh-rev0), I would guess posix support is important
 
@Severin, ah my thread model is win32, you get the point .. so that not defined in win32 thread model right?so how to enable posix support?
adding _GLIBCXX_USE_NANOSLEEP to 1 in c++config.h didint work either
 
Aha! I think we found the difference. I got mine from http://mingw-w64.sourceforge.net/download.php, get Mingw-builds project, download mingw-w64-install.exe from Sourceforge. Run it and select posix threading and dwarf/seh EH
And I selected not i686, but x64 build
 
is there mingw 5 version from mingw-w64-install.exe ?
 
3:01 PM
no, 4.9.2 is the last version
 
oh so sad, waiting for few months again, I dont want my whole a day being spent for building like this. But thanks for info
 
I would guess you might have both versions installed
 
There's a difference between -lpthread and -pthread. Use -pthread.
 
There is a version with posix threads enabled: sourceforge.net/projects/mingw-w64/files/… but the version is 4.9.2 and not 5.0. Are you sure you really need 5.0? 5.0 isn't even out yet.
 
Yes I need that, but I will try manage to compile from the source whole stack. But I dont know, I havent time this week for doing that
 

last day (14 days later) »