Some C ++ 11 features are missing when using code blocks 13.12, MinGW 4.8.1, and SFML 2.1

Going to stack overflow after exhausting all my efforts.
I am running Code Blocks 13.12 and MinGW 4.8.1 on a 64 bit Windows 7 OS system. I spent two days trying to get the compiler to link (statically) with the SFML 2.1 library. I completed both the SFML tutorial and this video tutorial - reinstall both blocks of code and MinGW two times before it finally connects.
After that, I was released that SFML was recognized, but I had 50 errors when I tried to create and run that the proposed C ++ 11 features were not.
Added -std=gnu++11 to the compiler options and 13 of these errors disappeared.
The remaining errors fall into two categories: mutex is not a member of std and , since time t, is not a member of chrono :: _ V2 :: stable clock . I'm not even sure what _V2 is.

What am I missing?

 -------------- Build: Release in PumpTracker2.0 (compiler: GNU GCC Compiler)--------------- mingw32-g++.exe -Wall -std=gnu++11 -DSFML_STATIC -O2 -std=gnu++11 -IC:\SFML-2.1\include -IC:\SFML-2.1\include -c C:\Users\WITcom\Desktop\C++\PumpTracker2.0\main.cpp -o obj\Release\main.o In file included from C:\Users\WITcom\Desktop\C++\PumpTracker2.0\main.cpp:25:0: C:\Users\WITcom\Desktop\C++\PumpTracker2.0\Account.h:37:1: error: 'mutex' in namespace 'std' does not name a type std::mutex mu; ^ C:\Users\WITcom\Desktop\C++\PumpTracker2.0\Account.h:86:22: error: 'to_time_t' is not a member of 'std::chrono::_V2::steady_clock' time_t currentTp = std::chrono::steady_clock::to_time_t(newly); C:\Users\WITcom\Desktop\C++\PumpTracker2.0\Account.h:94:48: error: 'from_time_t' is not a member of 'std::chrono::_V2::steady_clock' std::chrono::steady_clock::time_point tNew = std::chrono::steady_clock::from_time_t(currentTp); ^ C:\Users\WITcom\Desktop\C++\PumpTracker2.0\main.cpp:51:2: error: 'mutex' is not a member of 'std' std::mutex mu3; ^ C:\Users\WITcom\Desktop\C++\PumpTracker2.0\main.cpp:51:13: error: expected ';' before 'mu3' std::mutex mu3; ^ C:\Users\WITcom\Desktop\C++\PumpTracker2.0\main.cpp:52:19: error: 'mutex' was not declared in this scope std::unique_lock<mutex> locker3(mu3, std::defer_lock); ^ C:\Users\WITcom\Desktop\C++\PumpTracker2.0\main.cpp:52:24: error: template argument 1 is invalid std::unique_lock<mutex> locker3(mu3, std::defer_lock); ^ C:\Users\WITcom\Desktop\C++\PumpTracker2.0\main.cpp:52:33: error: invalid type in declaration before '(' token std::unique_lock<mutex> locker3(mu3, std::defer_lock); C:\Users\WITcom\Desktop\C++\PumpTracker2.0\main.cpp:214:22: error: 'to_time_t' is not a member of 'std::chrono::_V2::steady_clock' pS->tpNewest = std::chrono::steady_clock::to_time_t(NextPump); ^ C:\Users\WITcom\Desktop\C++\PumpTracker2.0\main.cpp:245:51: error: 'from_time_t' is not a member of 'std::chrono::_V2::steady_clock' std::chrono::steady_clock::time_point TT2 = std::chrono::steady_clock::from_time_t(pS->tpNewest); ^ Process terminated with status 1 (0 minute(s), 4 second(s)) 37 error(s), 47 warning(s) (0 minute(s), 4 second(s)) 
+3
c ++ 11 mingw codeblocks sfml
Jan 12 '14 at 14:33
source share
1 answer

As already mentioned, the initial MinGW distribution is not the best you can go with if you want to go with modern features. Instead, there are projects such as Nuwen (Stephan T. Lavavej website), as well as MinGW Builds that provide MinGW-w64 binaries.

Mentioning SFML is misleading since the problems are not related to SFML at all. Keep in mind that you will have to rebuild SFML if you change the compiler!

As a next step, it would be important to publish a minimal example of source code that reproduces errors, because right now we can only guess what is going wrong, based on errors.

If you are not using GNU extensions explicitly, you should use -std=c++11 instead of -std=gnu++11 , and if you look at the build command, you will notice that it turns on twice, which is optional.

And now to some assumptions about errors:

  • Account.h - Make sure the <mutex> header is included.
  • main.cpp - Make sure the <mutex> header is included.
  • main.cpp - If std::unique_lock<mutex> from your code, you need to add std:: , i.e. std::unique_lock<std::mutex> .
  • main.cpp - time_t everything seems to be resolved, but be sure to include <chrono> and <ctime > (since time_t is defined in <ctime> ).
0
Jan 13 '14 at 9:22
source share



All Articles