jeudi 3 octobre 2019

g++ 4.4.7 error: namespace "std" has no member "random_device"

I am trying to run a code on a linux cluster with g++ 4.4.7 but it is giving me the following error:

/usr/include/c++/4.4.7/c++0x_warning.h(31): error: #error directive: 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.
#error This file requires compiler and library support for the upcoming \ ^

xpfc-mpi.cpp(80): error: namespace "std" has no member "random_device" std::random_device rd; // obtain a random number from the hardware ^

xpfc-mpi.cpp(81): error: namespace "std" has no member "mt19937"
std::mt19937 eng(rd()); // seed the generator ^

xpfc-mpi.cpp(82): error: namespace "std" has no member "normal_distribution" std::normal_distribution distribution(mean, std_dev);

"random" part of my code

const double mean =0;
const double std_dev = 1;
std::random_device rd; // obtain a random number from the hardware
std::mt19937 eng(rd()); // seed the generator
std::normal_distribution<double> distribution(mean, std_dev);
double ix;
ix = distribution(eng);

The code runs on my laptop I am using WSL Ubuntu with g++ 7.4.0, I don't have root access in the cluster so I can't change it to match my laptop.

I tried using mpic++ -std=gnu++0x to compile my code but it still gives same error.

Any suggestions on how to run the code?

Aucun commentaire:

Enregistrer un commentaire