【问题标题】:Google Test compilation error from gtest-all.cc来自 gtest-all.cc 的 Google 测试编译错误
【发布时间】:2013-08-19 18:17:10
【问题描述】:

我正在尝试用我的测试用例编译 google 测试,但不能。我没有对 gtest_main.cc 或 gtest-all.cc 文件进行任何更改,即使这样我也无法编译这些文件。 我收到以下错误:

g++ -g -Wall -Wextra -Werror -I../../../ext/gtest-1.6.0/include -I../../../ext/gtest-1.6.0 -c ../../../ext/gtest-1.6.0/src/gtest-all.cc
In file included from ../../../ext/gtest-1.6.0/src/gtest.cc:35,
             from ../../../ext/gtest-1.6.0/src/gtest-all.cc:42:
../../../ext/gtest-1.6.0/include/gtest/gtest-spi.h:52: error: expected initializer before ‘:’ token
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.4.4/../../../../include/c++/4.4.4/ext/atomicity.h:34,
             from /usr/lib/gcc/x86_64-redhat-linux/4.4.4/../../../../include/c++/4.4.4/bits/ios_base.h:41,
             from /usr/lib/gcc/x86_64-redhat-linux/4.4.4/../../../../include/c++/4.4.4/ios:43,
             from /usr/lib/gcc/x86_64-redhat-linux/4.4.4/../../../../include/c++/4.4.4/ostream:40,
             from ../../../ext/gtest-1.6.0/src/gtest.cc:46,
             from ../../../ext/gtest-1.6.0/src/gtest-all.cc:42:
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/../../../../include/c++/4.4.4/x86_64-redhat-linux/bits/gthr.h:30: error: expected ‘}’ before end of line
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/../../../../include/c++/4.4.4/x86_64-redhat-linux/bits/gthr.h:30: error: expected declaration before end of line

但是我可以编译 gtest_main.cc 而没有任何错误:

   g++ -g -Wall -Wextra -Werror -I../../../ext/gtest-1.6.0/include -I../../../ext/gtest-1.6.0 -c ../../../ext/gtest-1.6.0/src/gtest-all.cc

谷歌也找不到任何帮助..!!提前感谢您的帮助。

【问题讨论】:

    标签: compiler-errors g++ googletest


    【解决方案1】:

    当我尝试按照这篇文章手动安装它时遇到了同样的问题:Arturo Ruiz Mañas' response。 它没有用,所以我也厌倦了该帖子中的另一个选项,但我已经在 /usr/local/include 中添加了标题。

    检查是否添加了旧标头并尝试@detrick 版本的安装。

    【讨论】:

      猜你喜欢
      • 2015-12-02
      • 1970-01-01
      • 1970-01-01
      • 2021-02-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-04
      • 1970-01-01
      相关资源
      最近更新 更多