我想使用没有C++11的库,但它不会为我编译:(理论上它应该按照文档@http://easylogging.muflihun.com:“对于较低版本的C++ (非C++11),请考虑使用Easylogging++ v8.91。")
error:#error此文件需要支持C++ 2011标准的编译器和库。这种支持目前还处于实验阶段,必须使用-std=c++11或-std=gnu++11编译器选项来启用。
文件结构:
./Main.cpp./logger/easylogging++.h
Main.cpp的内容:
#include "logger/easylogging++.h"
_INITIALIZE_EASYLOGGINGPP
using namespace std;
int main(int argc, char* argv[]) {
LINFO << "This is my first log";
return 0;
}../src/logger/easylogging++.h: In function‘std::string easyloggingpp::internal::threading::getCurrentThreadId()’:../src/logger/easylogging++.h:691:16: error:’std::this_thread‘尚未声明为ss << std::this_thread::get_id();
编译器: gcc 4.8.2版(Ubuntu 4.8.2-19ubuntu1),操作系统: Ubuntu 14.04 LTS
发布于 2016-09-08 10:36:36
正如T.C.在解决方案中建议的那样,更改easylogging++.h顶部的这段代码:
#if defined(__GNUC__)
# define _ELPP_GCC_VERSION (__GNUC__ * 10000 \
+ __GNUC_MINOR__ * 100 \
+ __GNUC_PATCHLEVEL__)
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
# define _ELPP_CXX0X 1
# elif (_ELPP_GCC_VERSION >= 40801)
# define _ELPP_CXX11 1
# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
#endif // defined(__GNUC__)将_ELPP_CXX0X和_ELPP_CXX11都更改为0将解决此问题。
https://stackoverflow.com/questions/29332253
复制相似问题