qpp
qpp copied to clipboard
Tests fail to link due to missing -lgtest
ld: error: undefined symbol: testing::Test::TearDown()
>>> referenced by qdummy_engine.cpp
>>> unit_tests/CMakeFiles/unit_tests.dir/tests/classes/qdummy_engine.cpp.o:(vtable for qpp_QDummyEngine_execute_Iterator_Test)
>>> referenced by qdummy_engine.cpp
>>> unit_tests/CMakeFiles/unit_tests.dir/tests/classes/qdummy_engine.cpp.o:(vtable for qpp_QDummyEngine_execute_ValueType_Test)
>>> referenced by qdummy_engine.cpp
>>> unit_tests/CMakeFiles/unit_tests.dir/tests/classes/qdummy_engine.cpp.o:(vtable for qpp_QDummyEngine_execute_AllCircuitWithRepetitions_Test)
>>> referenced 438 more times
Adding -lgtest like this fixes the problem:
--- unit_tests/CMakeLists.txt.orig 2024-03-04 21:51:04 UTC
+++ unit_tests/CMakeLists.txt
@@ -40,5 +40,5 @@ endforeach()
target_sources(${TARGET_NAME} PUBLIC ${file})
endforeach()
-target_link_libraries(${TARGET_NAME} PUBLIC ${QPP_LINK_DEPS} gmock libqpp)
+target_link_libraries(${TARGET_NAME} PUBLIC ${QPP_LINK_DEPS} gtest gmock libqpp)
gtest_discover_tests(${TARGET_NAME})
Version: 5.1 clang-16 OS: FreeBSD 14.0
@yurivict In 5.1 we've updated the library so it installs the latest Google Test on demand. Now you just need to compile with cmake -B build followed by cmake --build build/unit_tests --target unit_tests. No more -D flags for cmake. I've tested it on FreeBSD 14.0 and I'm not getting any linker errors. Can you try again and let us know? Thanks!