OS:centos 7
g++ version: 8.3.1 set -std=c++17
gtest installed by such way:sudo yum install epel-release
sudo yum install dnf
sudo dnf install dnf-plugins-core
sudo dnf install gtest gtest-devel
it throw link error:
[root@DESKTOP-M5G7V2R thread-pool-cpp]# mkdir build
[root@DESKTOP-M5G7V2R thread-pool-cpp]# cd build/; cmake -DCMAKE_BUILD_TYPE=Release ..;clear ;make VERBOSE=1
-- The CXX compiler identification is GNU 8.3.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (1.2s)
-- Generating done (0.0s)
/usr/local/bin/cmake -S/home/thread-pool-cpp -B/home/thread-pool-cpp/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/local/bin/cmake -E cmake_progress_start /home/thread-pool-cpp/build/CMakeFiles /home/thread-pool-cpp/build//CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory /home/thread-pool-cpp/build' make -f CMakeFiles/HEADER_ONLY_TARGET.dir/build.make CMakeFiles/HEADER_ONLY_TARGET.dir/depend make[2]: Entering directory
/home/thread-pool-cpp/build'
cd /home/thread-pool-cpp/build && /usr/local/bin/cmake -E cmake_depends "Unix Makefiles" /home/thread-pool-cpp /home/thread-pool-cpp /home/thread-pool-cpp/build /home/thread-pool-cpp/build /home/thread-pool-cpp/build/CMakeFiles/HEADER_ONLY_TARGET.dir/DependInfo.cmake "--color="
make[2]: Leaving directory /home/thread-pool-cpp/build' make -f CMakeFiles/HEADER_ONLY_TARGET.dir/build.make CMakeFiles/HEADER_ONLY_TARGET.dir/build make[2]: Entering directory
/home/thread-pool-cpp/build'
[ 11%] Linking CXX static library libHEADER_ONLY_TARGET.a
/usr/local/bin/cmake -P CMakeFiles/HEADER_ONLY_TARGET.dir/cmake_clean_target.cmake
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/HEADER_ONLY_TARGET.dir/link.txt --verbose=1
/usr/bin/ar qc libHEADER_ONLY_TARGET.a
/usr/bin/ranlib libHEADER_ONLY_TARGET.a
make[2]: Leaving directory /home/thread-pool-cpp/build' [ 11%] Built target HEADER_ONLY_TARGET make -f tests/CMakeFiles/fixed_function_test.dir/build.make tests/CMakeFiles/fixed_function_test.dir/depend make[2]: Entering directory
/home/thread-pool-cpp/build'
cd /home/thread-pool-cpp/build && /usr/local/bin/cmake -E cmake_depends "Unix Makefiles" /home/thread-pool-cpp /home/thread-pool-cpp/tests /home/thread-pool-cpp/build /home/thread-pool-cpp/build/tests /home/thread-pool-cpp/build/tests/CMakeFiles/fixed_function_test.dir/DependInfo.cmake "--color="
make[2]: Leaving directory /home/thread-pool-cpp/build' make -f tests/CMakeFiles/fixed_function_test.dir/build.make tests/CMakeFiles/fixed_function_test.dir/build make[2]: Entering directory
/home/thread-pool-cpp/build'
[ 22%] Building CXX object tests/CMakeFiles/fixed_function_test.dir/fixed_function.t.cpp.o
cd /home/thread-pool-cpp/build/tests && /usr/bin/g++ -I/usr/local/include/gtest -I/home/thread-pool-cpp/include -I/home/thread-pool-cpp/tests -std=c++17 -Wall -Wextra -lgtest -O3 -DNDEBUG -MD -MT tests/CMakeFiles/fixed_function_test.dir/fixed_function.t.cpp.o -MF CMakeFiles/fixed_function_test.dir/fixed_function.t.cpp.o.d -o CMakeFiles/fixed_function_test.dir/fixed_function.t.cpp.o -c /home/thread-pool-cpp/tests/fixed_function.t.cpp
[ 33%] Linking CXX executable fixed_function_test
cd /home/thread-pool-cpp/build/tests && /usr/local/bin/cmake -E cmake_link_script CMakeFiles/fixed_function_test.dir/link.txt --verbose=1
/usr/bin/g++ -std=c++17 -Wall -Wextra -lgtest -O3 -DNDEBUG CMakeFiles/fixed_function_test.dir/fixed_function.t.cpp.o -o fixed_function_test -lpthread -lgtest -lgtest_main
CMakeFiles/fixed_function_test.dir/fixed_function.t.cpp.o: In function FixedFunction_allocDealloc_Test::TestBody()': fixed_function.t.cpp:(.text+0x15de): undefined reference to
testing::internal::EqFailure(char const*, char const*, std::string const&, std::string const&, bool)'
CMakeFiles/fixed_function_test.dir/fixed_function.t.cpp.o: In function _GLOBAL__sub_I__Z14test_free_funci': fixed_function.t.cpp:(.text.startup+0x1fa): undefined reference to
testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, testing::internal::CodeLocation, void const*, void ()(), void ()(), testing::internal::TestFactoryBase*)'
fixed_function.t.cpp:(.text.startup+0x2c0): undefined reference to testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, testing::internal::CodeLocation, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)' fixed_function.t.cpp:(.text.startup+0x386): undefined reference to
testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, testing::internal::CodeLocation, void const*, void ()(), void ()(), testing::internal::TestFactoryBase*)'
fixed_function.t.cpp:(.text.startup+0x44c): undefined reference to testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, testing::internal::CodeLocation, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)' fixed_function.t.cpp:(.text.startup+0x512): undefined reference to
testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, testing::internal::CodeLocation, void const*, void ()(), void ()(), testing::internal::TestFactoryBase*)'
CMakeFiles/fixed_function_test.dir/fixed_function.t.cpp.o:fixed_function.t.cpp:(.text.startup+0x5d8): more undefined references to testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, testing::internal::CodeLocation, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)' follow CMakeFiles/fixed_function_test.dir/fixed_function.t.cpp.o: In function
testing::AssertionResult testing::internal::CmpHelperEQ<std::string, std::string>(char const*, char const*, std::string const&, std::string const&)':
fixed_function.t.cpp:(.text.ZN7testing8internal11CmpHelperEQISsSsEENS_15AssertionResultEPKcS4_RKT_RKT0[ZN7testing8internal11CmpHelperEQISsSsEENS_15AssertionResultEPKcS4_RKT_RKT0]+0x57): undefined reference to testing::internal::EqFailure(char const*, char const*, std::string const&, std::string const&, bool)' CMakeFiles/fixed_function_test.dir/fixed_function.t.cpp.o: In function
testing::AssertionResult testing::internal::CmpHelperEQ<int, unsigned long>(char const*, char const*, int const&, unsigned long const&)':
fixed_function.t.cpp:(.text.ZN7testing8internal11CmpHelperEQIimEENS_15AssertionResultEPKcS4_RKT_RKT0[ZN7testing8internal11CmpHelperEQIimEENS_15AssertionResultEPKcS4_RKT_RKT0]+0x4b): undefined reference to testing::internal::EqFailure(char const*, char const*, std::string const&, std::string const&, bool)' CMakeFiles/fixed_function_test.dir/fixed_function.t.cpp.o: In function
testing::AssertionResult testing::internal::CmpHelperEQ<int, int>(char const*, char const*, int const&, int const&)':
fixed_function.t.cpp:(.text.ZN7testing8internal11CmpHelperEQIiiEENS_15AssertionResultEPKcS4_RKT_RKT0[ZN7testing8internal11CmpHelperEQIiiEENS_15AssertionResultEPKcS4_RKT_RKT0]+0x4a): undefined reference to testing::internal::EqFailure(char const*, char const*, std::string const&, std::string const&, bool)' collect2: error: ld returned 1 exit status make[2]: *** [tests/fixed_function_test] Error 1 make[2]: Leaving directory
/home/thread-pool-cpp/build'
make[1]: *** [tests/CMakeFiles/fixed_function_test.dir/all] Error 2
make[1]: Leaving directory `/home/thread-pool-cpp/build'
make: *** [all] Error 2