ubuntu下googletest安装教程及报错解决办法

Googletest安装流程

1、从官网下载ubuntu下安装的source文件,下载链接为:
https://github.com/google/googletest.git
2、解压之后,cd到对应目录中,然后使用cmake进行编译,再进行make生成两个静态库libgtest.a libgtest_main.a,操作流程为:

cd ~/software/googletest-master
mkdir build
cd build
cmake ../googletest/
make

3、将步骤2中生成的两个库文件及/googletest/include/gtest文件,复制到用户目录下,操作如下:

sudo cp libgtest*.a  /usr/lib 
sudo cp -a /home/bruce/software/googletest-master/googletest/include/gtest /usr/include

至此Googletest就已经安装完成。

Googletest在make时报错

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.


cc1plus: all warnings being treated as errors
CMakeFiles/gtest.dir/build.make:62: recipe for target ‘CMakeFiles/gtest.dir/src/gtest-all.cc.o’ failed
make[2]: *** [CMakeFiles/gtest.dir/src/gtest-all.cc.o] Error 1
CMakeFiles/Makefile2:104: recipe for target ‘CMakeFiles/gtest.dir/all’ failed
make[1]: *** [CMakeFiles/gtest.dir/all] Error 2
Makefile:83: recipe for target ‘all’ failed
make: *** [all] Error 2
解决办法:
在安装包的googletest文件夹下(/home/bruce/software/googletest-master/googletest)找到CmakeLists.txt, 在其中添加如下语句:

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

再次make,便可以成功!

  • 6
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值