gtest 编译Error解决 error: is_trivially_copy_constructible is not a member of std
Centos 7.2
gtest: googletest-release-1.11.0
1. 升级gcc 4.8 -> 7.3
$ sudo yum install centos-release-scl
$ sudo yum install devtoolset-7-gcc*
$ scl enable devtoolset-7 bash
$ which gcc
$ gcc --version
2. Top CMakeLists.txt 加入:
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_definitions(-D_GLIBCXX_USE_C99=1)
3. 再次重新编译
$ cd build
$ cmake ..
$ make
[ 12%] Building CXX object googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o
[ 25%] Linking CXX static library ../lib/libgtest.a
[ 25%] Built target gtest
[ 37%] Building CXX object googlemock/CMakeFiles/gmock.dir/src/gmock-all.cc.o
[ 50%] Linking CXX static library ../lib/libgmock.a
[ 50%] Built target gmock
[ 62%] Building CXX object googlemock/CMakeFiles/gmock_main.dir/src/gmock_main.cc.o
[ 75%] Linking CXX static library ../lib/libgmock_main.a
[ 75%] Built target gmock_main
[ 87%] Building CXX object googletest/CMakeFiles/gtest_main.dir/src/gtest_main.cc.o
[100%] Linking CXX static library ../lib/libgtest_main.a
[100%] Built target gtest_main
$ sudo make install
成功了。