qpp icon indicating copy to clipboard operation
qpp copied to clipboard

Tests fail to link due to missing -lgtest

Open yurivict opened this issue 1 year ago • 1 comments

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 avatar Mar 04 '24 21:03 yurivict

@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!

vsoftco avatar Mar 05 '24 18:03 vsoftco