-3

I have an error on my compile

Picture Of The Error

I tried to fix it by downloading and installing gcc-tdm, because a forum mentioned this is a compiler issue, but I am still getting the same result.

Does anyone know how to solve this?

Remy Lebeau
  • 454,445
  • 28
  • 366
  • 620
Chris
  • 11
  • 1
  • 5
  • Make sure you are using C++11 or later (C++14/17). – Michael Albers Aug 05 '17 at 15:35
  • Yea ..its check in global compiler setting – Chris Aug 05 '17 at 15:39
  • 1
    Whichj version of TDM GCC are you using? Post the output of running `g++ -v`. –  Aug 05 '17 at 15:45
  • GCC's x86_64-w64-mingw32. What do you mean by Post the output of running g++ -v. I just download the exe and installed it. – Chris Aug 05 '17 at 15:55
  • Run the command `g++ -v` from the command line. –  Aug 05 '17 at 16:26
  • C:\Users\Chris_D>g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=C:/TDM-GCC-64/bin/../libexec/gcc/x86_64-w64-mingw32/5.1.0/lto-wrapper.exe Target: x86_64-w64-mingw32 Configured with: ../../../src/gcc-5.1.0/configure --build=x86_64-w64-mingw32 --enable-targets=all --enable-languages=ada,c,c++,fortran,lto,objc,obj-c++ --enable-libgomp --enable-lto --enable-graphite --enable-cxx-flags=-DWINPTHREAD_STATIC --disable-build-with-cxx --disable-build-poststage1-with-cxx --enable-libstdcxx-debug --enable-threads=posix --enable-version-specific-runtime-libs --enable-fully-dynam..etc – Chris Aug 05 '17 at 16:32
  • That looks OK - what happens when you compile your code from the command line? –  Aug 05 '17 at 16:42
  • i use codeblocks to compile it and it says ||=== Build: Debug in Keylog (compiler: GNU GCC Compiler) ===| C:\Users\Chris_D\Desktop\New folder\Keylog\Timer.h|10|error: 'thread' in namespace 'std' does not name a type| C:\Users\Chris_D\Desktop\New folder\Keylog\Timer.h||In member function 'void Timer::SleepAndRun()':| C:\Users\Chris_D\Desktop\New folder\Keylog\Timer.h|22|error: 'std::this_thread' has not been declared| – Chris Aug 05 '17 at 16:44
  • Copy&paste the real compiler output. No images! –  Aug 05 '17 at 16:46
  • i updated the image with the the compiler output. and i paste what it say before your comment. – Chris Aug 05 '17 at 16:50
  • I say again, what happens when you compile your code from the command line? –  Aug 05 '17 at 16:56
  • I don't compile the code on the command line, I use CodeBlocks, and it compile for me. – Chris Aug 05 '17 at 17:24
  • Stackoverflow is _not_ a forum so drop the [solved]. Read the [faq] and certainly read [ask] for information on what constitutes a good question. – dandan78 Aug 05 '17 at 17:51

2 Answers2

1

Faced this issue just this morning. After reading up on it a bit, I realised I had MinGW with Win32 threads installed. A new clean install of MinGW with posix threads

https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/installer/mingw-w64-install.exe/download

and the issue gets resolved.

Link to original Win32 vs pthread post : mingw-w64 threads: posix vs win32

0

The version of GCC that CodeBlocks ships with doesn't support threads (or at least it was the case last time I checked). You'll have to install a better compiler, and configure CB to use it.

You can get a fresh version of GCC from MSYS2. Or you can install one of the numerous MinGW-w64 distributions.

HolyBlackCat
  • 45,832
  • 5
  • 81
  • 134