error: 'random_device' was not declared in this scope

c++11, qt, qt-creator, random

Solution

Make sure you include the header:

#include <random>

and you may need to add std:: in front of random_device, unless you have mapped 'std' into your namespace using

using namespace std;

Note: It is generally preferable to explicitly specify std:: as opposed to mapping namespaces into your default namespace.

Problem

I tried fixing this : c++0x_warning.h:32: Fehler:#error This file requires compiler and library support for the upcoming ISO C++ standard, C++0x. This support is currently experimental, and must be enabled with the -std=c++0x or -std=gnu++0x compiler options. by adding QMAKE_CXXFLAGS += -std=c++0x to my .pro file. Now I'm getting this error: error: 'random_device' was not declared in this scope random_device rd; ^

Original source