Tommizzy
Tommizzy

Reputation: 161

mt19937 is not a member of std possible makefile issue

In my program I use std::mt19937 to generate random numbers. On two systems (latest windows and ubuntu) the program compiles fine. But, on a third unknown system (using make) I get the error message: " 'mt19937' is not a member of 'std' "

I am assuming the makefile isn't written correctly. I am new to makefiles and not sure where to start. Do I need to enforce c++11? How would I do so?

all:

%.o: %.cc
    g++ -c -O2 -Wall -Wextra -pedantic $<

library-objects = \
    BigUnsigned.o \
    BigInteger.o \
    BigIntegerAlgorithms.o \
    BigUnsignedInABase.o \
    BigIntegerUtils.o \

library-headers = \
    NumberlikeArray.hh \
    BigUnsigned.hh \
    BigInteger.hh \
    BigIntegerAlgorithms.hh \
    BigUnsignedInABase.hh \
    BigIntegerLibrary.hh \

library: $(library-objects)

$(library-objects): $(library-headers)

# Components of the program.
program = rsa435
program-objects = rsa435.o

$(program-objects) : $(library-headers)

$(program) : $(program-objects) $(library-objects)
    g++ $^ -o $@

clean :
    rm -f $(library-objects) $(testsuite-cleanfiles) $(program-objects) $(program)

all : library $(program)

EDIT: It might be worth mentioning that I have both cc files and cpp files. Maybe this is causing an issue as well?

Upvotes: 2

Views: 6385

Answers (2)

Adel Ben Hamadi
Adel Ben Hamadi

Reputation: 770

"-std=c++11" is not enough , add #include<bits/stdc++.h>

Upvotes: 2

vharron
vharron

Reputation: 1207

The error is saying is that it knows about the "std" namespace but there is no "mt19937" defined in that namespace.

Add "-std=c++11" to your g++ command line because mt19937 wasn't defined until C++11.

(Credit: this was originally posted by Richard Critten as a comment to the question.)

Also, you might need to add this header file:

#include <random>

Upvotes: 3

Related Questions