Std random functions not working - Qt MinGw

I am using QtCreator 2.4.1, with QtSdk 4.8.1 and MinGw 4.7.2

I'm trying to use a (C ++ 11) random library, but I have been unsuccessful so far. Take the following code example:

#include <random>
...
std::default_random_engine generator;
std::uniform_int_distribution<int> distribution(1,6);
int dice_roll = distribution(generator);  // generates number in the range 1..6

      

The compiler complains:

error: 'default_random_engine' is not a member of 'std'

error: 'uniform_int_distribution' is not a member of 'std'

I have the -std = c ++ 0x flag in my .pro file. All other STL functions work fine, so I am puzzled! I would appreciate it if someone could help me.

0


source to share


2 answers


Well, stupid problem, but it can happen to others, so we go:

For some reason, my code compiled with MinGW 4.4, the default version that comes with my Qt Creator. To bring it back to MinGw 4.7.2, which I already installed on my computer, I clicked the Projects tab to the left of the QCreator screen, then selected the correct toolchain.



Thanks download Joachim Pileborg for pointing me in the right direction.

+1


source


I faced the same problem and was unable to change the compiler.

I replaced std :: rand () with qrand ()



http://qt-project.org/doc/qt-4.8/qtglobal.html#qrand

+1


source







All Articles