Linux知识点(13)_安装编译gtest中遇到的坑

1.下载gtest,release-1.8.0

git clone https://github.com/google/googletest

2.编译

cd googletest
mkdir build
cd build
cmake ..
make 

出现以下错误:

/usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support \
  ^
In file included from /home/liuzy/library/googletest/googletest/include/gtest/internal/gtest-internal.h:40:0,
                 from /home/liuzy/library/googletest/googletest/include/gtest/gtest.h:62,
                 from /home/liuzy/library/googletest/googletest/src/gtest-all.cc:38:
/home/liuzy/library/googletest/googletest/include/gtest/internal/gtest-port.h:985:1: error: identifier ‘nullptr’ is a keyword in C++11 [-Werror=c++0x-compat]
 inline void FlushInfoLog() { fflush(nullptr); }

仔细阅读错误内容,会发现要选择相应的编译环境,即打开googletest/CMakeLists.txt
添加以下行:

add_definitions(-std=c++11)

make就好了。
最后

sudo make install

你可能感兴趣的:(Linux知识点)