mt19937不是std可能的makefile问题的成员
在我的程序中,我使用std::mt19937生成随机数。在最新的windows和ubuntu两种系统上,该程序可以很好地编译。但是,在使用make的第三个未知系统上,我收到错误消息: “mt19937”不是“std”的成员 我假设makefile没有正确编写。我不熟悉makefile,不知道从哪里开始。我需要强制执行c++11吗?我该怎么做mt19937不是std可能的makefile问题的成员,makefile,g++,Makefile,G++,在我的程序中,我使用std::mt19937生成随机数。在最新的windows和ubuntu两种系统上,该程序可以很好地编译。但是,在使用make的第三个未知系统上,我收到错误消息: “mt19937”不是“std”的成员 我假设makefile没有正确编写。我不熟悉makefile,不知道从哪里开始。我需要强制执行c++11吗?我该怎么做 all: %.o: %.cc g++ -c -O2 -Wall -Wextra -pedantic $< library-objects
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文件。可能这也导致了问题?错误是它知道std名称空间,但该名称空间中没有定义mt19937 将-std=c++11添加到g++命令行,因为直到c++11才定义mt19937 信用证:这是理查德·克里滕最初对这个问题的评论 此外,您可能需要添加此头文件:
#include <random>
-std=c++11还不够,添加include你能提供这个未知系统的名称吗?我真的不知道,但我猜它是一个mac。将-std=c++11添加到你的g++行顶部或底部的那一个?肯定是处于编译阶段的顶部。不确定最下面的那一个是链接阶段。两种方法都尝试,除非出现错误。