1

我正在尝试用我的测试用例编译谷歌测试,但不能。我没有对 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

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

4

1 回答 1

0

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

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

于 2018-07-05T17:53:49.703 回答