在我的程序中,我使用std::mt19937来生成随机数。在两个系统(最新的windows和ubuntu)上,程序编译得很好。但是,在第三个未知的系统上(使用make),我得到错误消息:“'mt19937‘不是'std’的成员”。
我假设makefile写得不正确。我刚接触sure文件,不知道从哪里开始。我需要强制执行c++11吗?我该怎么做呢?
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)编辑:值得一提的是,我有cc文件和cpp文件。也许这也造成了一个问题?
发布于 2017-07-27 06:24:39
错误是它知道"std“名称空间,但在该名称空间中没有定义"mt19937”。
将"-std=c++11“添加到您的g++命令行,因为mt19937直到C++11才被定义。
(来源:这篇文章最初是Richard Critten发布的,作为对这个问题的评论。)
此外,您可能需要添加以下头文件:
#include <random>发布于 2020-01-14 16:55:04
"-std=c++11“不够,请添加#include<bits/stdc++.h>
https://stackoverflow.com/questions/42486596
复制相似问题