Googletest: Error during compile gtest

Created on 2 Aug 2019  Â·  5Comments  Â·  Source: google/googletest

My operation is shown itemized:
yum install git
yum install gcc-c++
yum install cmake
yum install python
yum install zeromq-devel

Then : git clone https://github.com/google/googletest.git

cd /googletest/googletest
[root@VM_16_11_centos googletest]# cmake CMakeLists.txt
-- Configuring done
-- Generating done
-- Build files have been written to: /usr/local/qiuxin/googletest/googletest
[root@VM_16_11_centos googletest]# make

Huge Error here!!!

In file included from /usr/local/qiuxin/googletest/googletest/src/gtest-all.cc:38:0:
/usr/local/qiuxin/googletest/googletest/include/gtest/gtest.h: In member function 'virtual testing::Test::Setup_should_be_spelled_SetUp* testing::Test::Setup()':
/usr/local/qiuxin/googletest/googletest/include/gtest/gtest.h:513:68: error: control reaches end of non-void function [-Werror=return-type]
virtual Setup_should_be_spelled_SetUp* Setup() { return nullptr; }
^
cc1plus: all warnings being treated as errors
make[2]: * [CMakeFiles/gtest.dir/src/gtest-all.cc.o] Error 1
make[1]:
[CMakeFiles/gtest.dir/all] Error 2
make: *
* [all] Error 2

All 5 comments

Check what version of gcc your build is using

Do me a favor to let me know whether gcc version is right.
[root@VM_16_11_centos ~]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)

As far as my understanding, gcc version 4.8.5 support C++11 .

BTW, if I use yum command to install the following two packages, I do NOT need to download the source code and compile it. Right?
https://centos.pkgs.org/7/okey-x86_64/gtest-1.8.0-3.el7.x86_64.rpm.html
https://centos.pkgs.org/7/okey-x86_64/gtest-devel-1.8.0-3.el7.x86_64.rpm.html

solved. The mistake I made was:
1) I created a build folder in the googletest/googletest directory.

The right operation should be:
1) Create a build folder in googletest directory(NOT googletest/googletest directory.).
then:
cd build
cmake .. -DBUILD_GTEST=ON -DBUILD_SHARED_LIBS=ON
make
sudo make install

Everything goes well!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nholthaus picture nholthaus  Â·  6Comments

ebioman picture ebioman  Â·  3Comments

cyberdecker picture cyberdecker  Â·  3Comments

Joebeazelman picture Joebeazelman  Â·  5Comments

maygamboa picture maygamboa  Â·  6Comments