0

I want to test to build googletest basic example, but I fail...
[Steps]

$ 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  

-- Configuring done
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
gTest_build_samples
--Build files have been written to /home/hughesyang/Test/googletest/mybuild

$ make ---> error occur!

Error message(snippet first 17 lines):
-- Configuring done
-- Generating done
-- Build files have been written to: /home/hughesyang/Test/googletest/mybuild
[ 3%] Building CXX object googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o
In file included from /home/hughesyang/Test/googletest/googletest/include/gtest/internal/gtest-death-test-internal.h:38:0,
from /home/hughesyang/Test/googletest/googletest/include/gtest/gtest-death-test.h:40,
from /home/hughesyang/Test/googletest/googletest/include/gtest/gtest.h:62,
from /home/hughesyang/Test/googletest/googletest/src/gtest-all.cc:38:
/home/hughesyang/Test/googletest/googletest/include/gtest/gtest-matchers.h: In static member function ‘static constexpr bool testing::internal::MatcherBase::IsInlined()’:
/home/hughesyang/Test/googletest/googletest/include/gtest/gtest-matchers.h:414:12: error: ‘is_trivially_copy_constructible’ is not a member of ‘std’ std::is_trivially_copy_constructible::value &&
^ /home/hughesyang/Test/googletest/googletest/include/gtest/gtest-matchers.h:414:50: error: expected primary-expression before ‘>’ token std::is_trivially_copy_constructible::value &&
^ /home/hughesyang/Test/googletest/googletest/include/gtest/gtest-matchers.h:414:51: error: ‘::value’ has not been declared std::is_trivially_copy_constructible::value &&
...

[Environment]
OS: CentOS 7.7
CMake ver: 3.21.2
GNU Make ver: 4.2.1
gcc ver: 9.3.1-2

Any suggestion is very useful!

Hughes
  • 121
  • 1
  • 11
  • 1
    CentOS 7 comes with gcc 4.8 which is very outdated (current stable release is 11.2) and it looks is not supported by the gtest version you are trying to use (it says gcc 5.0+ is needed on github readme). Probably the easiest way is to install [gtest-devel](https://centos.pkgs.org/7/epel-x86_64/gtest-devel-1.6.0-2.el7.x86_64.rpm.html) package from official [EPEL repository](https://www.tecmint.com/install-epel-repository-on-centos/) with older version of gtest which should be compatible with old gcc compiler they ship. – dewaffled Sep 04 '21 at 14:01
  • Hi dewaffled, Thanks for your reply! According to your suggestion. [First step] Updated gcc to 9.3.1-2, and then retry to "cmake -Dgtest_build_samples=ON ..". It don't show the warning now! But "make" shows the same error as topic. [Second step] Install gtest-devel by "yum --enablerepo=epel install gtest-devel-1.6.0-2.el7.x86_64". And retry "cmake -Dgtest_build_samples=ON .." & "make". However, it shows the same error message:( – Hughes Sep 05 '21 at 01:40
  • You can check with `g++ --version` what gcc version is being invoked. Most likely 9.3 is installed separately to /usr/local/bin or something. You can specify c++ compiler to use with `export CXX=/path/to/g++/binary` before calling cmake and make – dewaffled Sep 05 '21 at 10:10

1 Answers1

0

build googletest basic examples

Example, CentOS 7.9

git clone https://github.com/google/googletest.git
cd googletest/ && mkdir build && cd build/
CC=gcc84 CXX=g++84 cmake3 -Dgtest_build_samples=ON ..
               ## cmake3 (epel) is version 3.12.2-1.el7
make     ## no errors, the 10 samples are present in googletest/build/googletest/

gcc84, g++84: Item 9 → how to install gcc 4.9.2 on RHEL 7.4

Knud Larsen
  • 5,753
  • 2
  • 14
  • 19