Jump to content

View more

Image of the Day

Inventory ! Va falloir trouver une autre couleur pour le cadre D: #AzTroScreenshot #screenshotsaturday https://t.co/PvxhGL7cOH
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Having trouble compiling C++11 chrono with CodeBlocks, MinGW

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
3 replies to this topic

#1 lride   Members   

663
Like
0Likes
Like

Posted 01 December 2012 - 09:06 PM

I just installed code blocks and latest mingw today
The following code compiles fine on MSVS2012, but not on code blocks
[source lang="cpp"]#ifndef TIMER_H#define TIMER_H#include <chrono>class Timer{private: std::chrono::steady_clock::time_point startTime;public: Timer::Timer(): startTime(std::chrono::steady_clock::now()){} ~Timer(){} typedef std::chrono::duration<double> sec; double Timer::getElapsedTime() { return std::chrono::duration_cast<sec>(std::chrono::steady_clock::now()-startTime).count(); } void Timer::restart() { startTime=std::chrono::steady_clock::now(); }};#endif // TIMER_H[/source]
errors I get:

mingw32-g++.exe -Wall -O3 -O2 -std=c++0x -I"..\MinGW compiler test" -c "C:\Users\Park\Desktop\MinGW compiler test\main.cpp" -o obj\Release\main.o
In file included from C:\Users\Park\Desktop\MinGW compiler test\main.cpp:5:0:
C:\Users\Park\Desktop\MinGW compiler test\/include/Timer.h:8:2: error: 'steady_clock' in namespace 'std::chrono' does not name a type
C:\Users\Park\Desktop\MinGW compiler test\/include/Timer.h:10:2: error: extra qualification 'Timer::' on member 'Timer' [-fpermissive]
C:\Users\Park\Desktop\MinGW compiler test\/include/Timer.h:16:9: error: extra qualification 'Timer::' on member 'getElapsedTime' [-fpermissive]
C:\Users\Park\Desktop\MinGW compiler test\/include/Timer.h:20:7: error: extra qualification 'Timer::' on member 'restart' [-fpermissive]
C:\Users\Park\Desktop\MinGW compiler test\/include/Timer.h: In constructor 'Timer::Timer()':
C:\Users\Park\Desktop\MinGW compiler test\/include/Timer.h:10:18: error: class 'Timer' does not have any field named 'startTime'
C:\Users\Park\Desktop\MinGW compiler test\/include/Timer.h:10:41: error: 'std::chrono::steady_clock' has not been declared
C:\Users\Park\Desktop\MinGW compiler test\/include/Timer.h: In member function 'double Timer::getElapsedTime()':
C:\Users\Park\Desktop\MinGW compiler test\/include/Timer.h:18:55: error: 'std::chrono::steady_clock' has not been declared
C:\Users\Park\Desktop\MinGW compiler test\/include/Timer.h:18:75: error: 'startTime' was not declared in this scope
C:\Users\Park\Desktop\MinGW compiler test\/include/Timer.h: In member function 'void Timer::restart()':
C:\Users\Park\Desktop\MinGW compiler test\/include/Timer.h:22:3: error: 'startTime' was not declared in this scope
C:\Users\Park\Desktop\MinGW compiler test\/include/Timer.h:22:26: error: 'std::chrono::steady_clock' has not been declared
C:\Users\Park\Desktop\MinGW compiler test\main.cpp: In function 'int main()':
An invisible text.

#2 CyberRascal   Members   

208
Like
0Likes
Like

Posted 02 December 2012 - 12:14 PM

Really? Exactly that code? Chrono is in boost namespace..

#3 lride   Members   

663
Like
0Likes
Like

Posted 02 December 2012 - 01:27 PM

Really? Exactly that code? Chrono is in boost namespace..


I'm using std::chrono(c++11), not boost::chrono.
This compiled fine with MSVC 2012...
An invisible text.

#4 e‍dd   Members   

2109
Like
0Likes
Like

Posted 03 December 2012 - 05:42 AM

I would guess that the version of the C++ standard library that comes with Code::Blocks is not sufficiently recent. You could try to upgrade to the latest MinGW release, after researching whether or not it provides the std::chrono stuff.




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.