Your forgot to include random
, the header defining the mt19937 ("Mersenne Twister") generator.
Here is a complete example:
edd@max:/tmp$ cat cxx12_random.cpp
// use 'g++ -std=c++0x -o cxx12_random cxx12_random.cpp'
#include <random>
#include <iostream>
int main(int argc, char *argv[]) {
std::mt19937 engine(42);
std::normal_distribution<> normal(0.0, 1.0);
for (int i=0; i<5; i++) {
std::cout << normal(engine) << std::endl;
}
}
edd@max:/tmp$ g++ -std=c++0x -o cxx12_random cxx12_random.cpp
edd@max:/tmp$ ./cxx12_random
-0.550234
0.515433
0.473861
1.36845
-0.916827
edd@max:/tmp$
Note that I enabled the newer C++ extensions via -std=c++0x
. You may have to do the same with your compiler.