Ubuntu编译googletest报错

执行make时遇到遇到以下错误:

1

./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.

问题的解决方法:

在工程主目录的CMakeLists.txt中添加如下,可以编译成功:

SET(CMAKE_CXX_FLAGS "-std=c++0x")

 

2.

error: cannot find -lgtest

问题的解决方法:

通过参考文献进行make 后生成两个静态库:libgtest.a libgtest_main.a,将数据按照指定方式进行拷贝:

sudo cp libgtest*.a  /usr/lib 

sudo cp –a include/gtest /usr/include

同时,在CMakeLists.txt中加入:

include_directories(/home/...../googletest/include/gtest) 

注意:其中/home/...../googletest/include/gtest是你电脑中的绝对路径;

posted @ 2020-01-31 23:50  龙雪  阅读(417)  评论(0编辑  收藏  举报