yhirose / cpp-peglib

A single file C++ header-only PEG (Parsing Expression Grammars) library
MIT License
916 stars 113 forks source link

Tests fail to compile #281

Closed yurivict closed 1 year ago

yurivict commented 1 year ago
ld: error: undefined symbol: testing::Message::Message()
>>> referenced by test1.cc
>>>               test/CMakeFiles/peglib-test-main.dir/test1.cc.o:(GeneralTest_Simple_syntax_test_with_unicode_Test::TestBody())
>>> referenced by test1.cc
>>>               test/CMakeFiles/peglib-test-main.dir/test1.cc.o:(GeneralTest_Simple_syntax_test_Test::TestBody())
>>> referenced by test1.cc
>>>               test/CMakeFiles/peglib-test-main.dir/test1.cc.o:(GeneralTest_Empty_syntax_test_Test::TestBody())
>>> referenced 615 more times

ld: error: undefined symbol: testing::internal::GetBoolAssertionFailureMessage(testing::AssertionResult const&, char const*, char const*, char const*)
>>> referenced by test1.cc
>>>               test/CMakeFiles/peglib-test-main.dir/test1.cc.o:(GeneralTest_Simple_syntax_test_with_unicode_Test::TestBody())
>>> referenced by test1.cc
>>>               test/CMakeFiles/peglib-test-main.dir/test1.cc.o:(GeneralTest_Simple_syntax_test_Test::TestBody())
>>> referenced by test1.cc
>>>               test/CMakeFiles/peglib-test-main.dir/test1.cc.o:(GeneralTest_Empty_syntax_test_Test::TestBody())
>>> referenced 493 more times

ld: error: undefined symbol: testing::internal::AssertHelper::AssertHelper(testing::TestPartResult::Type, char const*, int, char const*)
>>> referenced by test1.cc
>>>               test/CMakeFiles/peglib-test-main.dir/test1.cc.o:(GeneralTest_Simple_syntax_test_with_unicode_Test::TestBody())
>>> referenced by test1.cc
>>>               test/CMakeFiles/peglib-test-main.dir/test1.cc.o:(GeneralTest_Simple_syntax_test_Test::TestBody())
>>> referenced by test1.cc
>>>               test/CMakeFiles/peglib-test-main.dir/test1.cc.o:(GeneralTest_Empty_syntax_test_Test::TestBody())
>>> referenced 615 more times

ld: error: undefined symbol: testing::internal::AssertHelper::operator=(testing::Message const&) const
>>> referenced by test1.cc
>>>               test/CMakeFiles/peglib-test-main.dir/test1.cc.o:(GeneralTest_Simple_syntax_test_with_unicode_Test::TestBody())
>>> referenced by test1.cc
>>>               test/CMakeFiles/peglib-test-main.dir/test1.cc.o:(GeneralTest_Simple_syntax_test_Test::TestBody())
>>> referenced by test1.cc
>>>               test/CMakeFiles/peglib-test-main.dir/test1.cc.o:(GeneralTest_Empty_syntax_test_Test::TestBody())
>>> referenced 615 more times

ld: error: undefined symbol: testing::internal::AssertHelper::~AssertHelper()
>>> referenced by test1.cc
>>>               test/CMakeFiles/peglib-test-main.dir/test1.cc.o:(GeneralTest_Simple_syntax_test_with_unicode_Test::TestBody())
>>> referenced by test1.cc
>>>               test/CMakeFiles/peglib-test-main.dir/test1.cc.o:(GeneralTest_Simple_syntax_test_with_unicode_Test::TestBody())
>>> referenced by test1.cc
>>>               test/CMakeFiles/peglib-test-main.dir/test1.cc.o:(GeneralTest_Simple_syntax_test_Test::TestBody())
>>> referenced 913 more times

ld: error: undefined symbol: testing::AssertionSuccess()
>>> referenced by test1.cc
>>>               test/CMakeFiles/peglib-test-main.dir/test1.cc.o:(GeneralTest_String_capture_test_Test::TestBody())
>>> referenced by test1.cc
>>>               test/CMakeFiles/peglib-test-main.dir/test1.cc.o:(GeneralTest_String_capture_test_Test::TestBody())
>>> referenced by test1.cc
>>>               test/CMakeFiles/peglib-test-main.dir/test1.cc.o:(GeneralTest_String_capture_test_Test::TestBody())
>>> referenced 102 more times

ld: error: undefined symbol: testing::internal::GetTestTypeId()
>>> referenced by test1.cc
>>>               test/CMakeFiles/peglib-test-main.dir/test1.cc.o:(_GLOBAL__sub_I_test1.cc)
>>> referenced by test1.cc
>>>               test/CMakeFiles/peglib-test-main.dir/test1.cc.o:(_GLOBAL__sub_I_test1.cc)
>>> referenced by test1.cc
>>>               test/CMakeFiles/peglib-test-main.dir/test1.cc.o:(_GLOBAL__sub_I_test1.cc)
>>> referenced 166 more times

ld: error: undefined symbol: testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, testing::internal::CodeLocation, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)
>>> referenced by test1.cc
>>>               test/CMakeFiles/peglib-test-main.dir/test1.cc.o:(_GLOBAL__sub_I_test1.cc)
>>> referenced by test1.cc
>>>               test/CMakeFiles/peglib-test-main.dir/test1.cc.o:(_GLOBAL__sub_I_test1.cc)
>>> referenced by test1.cc
>>>               test/CMakeFiles/peglib-test-main.dir/test1.cc.o:(_GLOBAL__sub_I_test1.cc)
>>> referenced 166 more times

Why use FetchContent? You should find externally installed googletest using find_package(GTest).

yhirose commented 1 year ago

@yurivict thanks for the report. But I have been using FetchContent for 2 years now, and I don't see any problem on my machine and GitHub Actions CI. Also I still prefer FetchContent to find_package, since I don't have to install gtest in advance into my machine, and I can download the exact version of gtest in the project folder. Thanks for your understanding!

image
yurivict commented 1 year ago

@yhirose Tests fail to link. See the errors above.

yurivict commented 11 months ago

The tests fail to link in 1.8.5:

[100% 1/1] : && /usr/local/libexec/ccache/c++ -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -isystem /usr/local/include -Wall -Wextra -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -isystem /usr/local/include  -DNDEBUG -fstack-protector-strong -L/usr/local/lib test/CMakeFiles/peglib-test-main.dir/test1.cc.o test/CMakeFiles/peglib-test-main.dir/test2.cc.o test/CMakeFiles/peglib-test-main.dir/test3.cc.o -o test/peglib-test-main  -lgtest_main && cd /usr/ports/textproc/cpp-peglib/work/.build/test && /usr/local/bin/cmake -D TEST_TARGET=peglib-test-main -D TEST_EXECUTABLE=/usr/ports/textproc/cpp-peglib/work/.build/test/peglib-test-main -D TEST_EXECUTOR= -D TEST_WORKING_DIR=/usr/ports/textproc/cpp-peglib/work/.build/test -D TEST_EXTRA_ARGS= -D TEST_PROPERTIES= -D TEST_PREFIX= -D TEST_SUFFIX= -D TEST_FILTER= -D NO_PRETTY_TYPES=FALSE -D NO_PRETTY_VALUES=FALSE -D TEST_LIST=peglib-test-main_TESTS -D CTEST_FILE=/usr/ports/textproc/cpp-peglib/work/.build/test/peglib-test-main[1]_tests.cmake -D TEST_DISCOVERY_TIMEOUT=5 -D TEST_XML_OUTPUT_DIR= -P /usr/local/share/cmake/Modules/GoogleTestAddTests.cmake
FAILED: test/peglib-test-main test/peglib-test-main[1]_tests.cmake /usr/ports/textproc/cpp-peglib/work/.build/test/peglib-test-main[1]_tests.cmake 
: && /usr/local/libexec/ccache/c++ -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -isystem /usr/local/include -Wall -Wextra -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -isystem /usr/local/include  -DNDEBUG -fstack-protector-strong -L/usr/local/lib test/CMakeFiles/peglib-test-main.dir/test1.cc.o test/CMakeFiles/peglib-test-main.dir/test2.cc.o test/CMakeFiles/peglib-test-main.dir/test3.cc.o -o test/peglib-test-main  -lgtest_main && cd /usr/ports/textproc/cpp-peglib/work/.build/test && /usr/local/bin/cmake -D TEST_TARGET=peglib-test-main -D TEST_EXECUTABLE=/usr/ports/textproc/cpp-peglib/work/.build/test/peglib-test-main -D TEST_EXECUTOR= -D TEST_WORKING_DIR=/usr/ports/textproc/cpp-peglib/work/.build/test -D TEST_EXTRA_ARGS= -D TEST_PROPERTIES= -D TEST_PREFIX= -D TEST_SUFFIX= -D TEST_FILTER= -D NO_PRETTY_TYPES=FALSE -D NO_PRETTY_VALUES=FALSE -D TEST_LIST=peglib-test-main_TESTS -D CTEST_FILE=/usr/ports/textproc/cpp-peglib/work/.build/test/peglib-test-main[1]_tests.cmake -D TEST_DISCOVERY_TIMEOUT=5 -D TEST_XML_OUTPUT_DIR= -P /usr/local/share/cmake/Modules/GoogleTestAddTests.cmake
/usr/local/bin/x86_64-unknown-freebsd14.0-ld: test/CMakeFiles/peglib-test-main.dir/test1.cc.o: undefined reference to symbol '_ZN7testing4Test5SetUpEv'
/usr/local/bin/x86_64-unknown-freebsd14.0-ld: /usr/local/lib/libgtest.so.1.14.0: error adding symbols: DSO missing from command line