【发布时间】:2021-09-04 13:50:28
【问题描述】:
我想测试构建 googletest 基本示例,但我失败了...
[步骤]
$ cd ~/Test/
$ git clone https://github.com/google/googletest
$ cd googletest ---> It's the first dir
$ mkdir mybuild
$ cd mybuild
$ cmake -Dgtest_build_samples=ON .. ---> One warning
-- 配置完成
-- 生成完成
CMake 警告:
项目未使用手动指定的变量:
gTest_build_samples
--构建文件已写入/home/hughesyang/Test/googletest/mybuild
$ make ---> error occur!
错误信息(sn-p 前 17 行):
-- 配置完成
-- 生成完成
-- 构建文件已写入:/home/hughesyang/Test/googletest/mybuild
[ 3%] 构建 CXX 对象 googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o
在 /home/hughesyang/Test/googletest/googletest/include/gtest/internal/gtest-death-test-internal.h:38:0 中包含的文件中,
来自 /home/hughesyang/Test/googletest/googletest/include/gtest/gtest-death-test.h:40,
来自 /home/hughesyang/Test/googletest/googletest/include/gtest/gtest.h:62,
来自 /home/hughesyang/Test/googletest/googletest/src/gtest-all.cc:38:
/home/hughesyang/Test/googletest/googletest/include/gtest/gtest-matchers.h:在静态成员函数'static constexpr bool testing::internal::MatcherBase::IsInlined()'中:
/home/hughesyang/Test/googletest/googletest/include/gtest/gtest-matchers.h:414:12:错误:‘is_trivially_copy_constructible’不是‘std’的成员
std::is_trivially_copy_constructible::value &&
^
/home/hughesyang/Test/googletest/googletest/include/gtest/gtest-matchers.h:414:50: error: 预期主表达式在“>”标记之前
std::is_trivially_copy_constructible::value &&
^
/home/hughesyang/Test/googletest/googletest/include/gtest/gtest-matchers.h:414:51: error: ‘::value’ 尚未声明
std::is_trivially_copy_constructible::value &&
...
[环境]
操作系统:CentOS 7.7
CMake 版本:3.21.2
GNU Make 版本:4.2.1
gcc 版本:9.3.1-2
任何建议都非常有用!
【问题讨论】:
-
CentOS 7 带有非常过时的 gcc 4.8(当前稳定版本是 11.2),并且看起来您尝试使用的 gtest 版本不支持(它说 github 上需要 gcc 5.0+自述文件)。可能最简单的方法是从官方EPEL repository 安装gtest-devel 软件包,使用旧版本的 gtest,它应该与他们提供的旧 gcc 编译器兼容。
-
您好 dewaffled,感谢您的回复!根据你的建议。 【第一步】更新gcc到9.3.1-2,然后重试“cmake -Dgtest_build_samples=ON ..”。它现在不显示警告!但是“make”显示与主题相同的错误。 【第二步】通过“yum --enablerepo=epel install gtest-devel-1.6.0-2.el7.x86_64”安装gtest-devel。并重试“cmake -Dgtest_build_samples=ON ..”和“make”。但是,它显示相同的错误消息:(
-
您可以通过
g++ --version检查正在调用的 gcc 版本。很可能 9.3 单独安装到 /usr/local/bin 或其他东西。您可以在调用 cmake 和 make 之前指定 c++ 编译器与export CXX=/path/to/g++/binary一起使用
标签: c++ centos7 googletest