Why random header not importing

2019-01-20 20:35发布

I have written code in C++ and compiled it by typing make. An error occurs:

/usr/include/c++/4.8/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.

2条回答
叛逆
2楼-- · 2019-01-20 21:14

The random library is using a newer version of the C++ standard (C++11). You need to modify your makefile to use the -std=c++11 flag. If you post your makefile contents I could advise you further, otherwise look at this question: Makefile modification to support c++11

Based on the cmakefile posted, add these lines to your cmakefile:

set_property(TARGET abc PROPERTY CXX_STANDARD 11)
set_property(TARGET abc PROPERTY CXX_STANDARD_REQUIRED ON)
查看更多
Deceive 欺骗
3楼-- · 2019-01-20 21:15

you need to add "-std=c++11" to your compiler arguments, telling it that it is a C++11 compile

$ g++ -std=c++11 your_file.cpp -o your_program

If you are using some IDE, you need to search the documentation to find out how to add this line so the compiler knows.

查看更多
登录 后发表回答