为什么我的 yaml 构建测试失败?yaml-cpp-0.6.0:handler_test.cpp:(.text+0x9f2):对“testing::internal::GetWithoutMatchers()”的引用未定义

为什么我的 yaml 构建测试失败?yaml-cpp-0.6.0:handler_test.cpp:(.text+0x9f2):对“testing::internal::GetWithoutMatchers()”的引用未定义

当我安装天文学软件 purify 时。它需要最新版本的 yaml,例如 yaml-cpp-0.6.0 我没有遇到任何错误,标准输出如下

-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Check for working C compiler: /home/luochong/software/gcc7.3/bin/gcc
-- Check for working C compiler: /home/luochong/software/gcc7.3/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /home/luochong/software/gcc7.3/bin/g++
-- Check for working CXX compiler: /home/luochong/software/gcc7.3/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test FLAG_WEXTRA
-- Performing Test FLAG_WEXTRA - Success
-- Found PythonInterp: /usr/bin/python (found version "2.7.12") 
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Configuring done
-- Generating done
-- Build files have been written to: /home/luochong/Downloads/yaml-cpp-yaml-cpp-0.6.0/build

看起来还不错。但是当我在 Linux shell 中输入“make”时,它在构建过程结束时抛出一个错误,似乎没有通过一些测试。我需要安装单独的测试框架吗?

[100%] Linking CXX executable run-tests
CMakeFiles/run-tests.dir/integration/handler_spec_test.cpp.o: In function `YAML::(anonymous namespace)::HandlerSpecTest_Ex2_1_SeqScalars_Test::TestBody()':
handler_spec_test.cpp:(.text+0x9002): undefined reference to `testing::internal::GetWithoutMatchers()'
handler_spec_test.cpp:(.text+0x90b3): undefined reference to `testing::internal::GetWithoutMatchers()'
handler_spec_test.cpp:(.text+0x919a): undefined reference to `testing::internal::GetWithoutMatchers()'
handler_spec_test.cpp:(.text+0x9281): undefined reference to `testing::internal::GetWithoutMatchers()'
handler_spec_test.cpp:(.text+0x9368): undefined reference to `testing::internal::GetWithoutMatchers()'
CMakeFiles/run-tests.dir/integration/handler_spec_test.cpp.o:handler_spec_test.cpp:(.text+0x9419): more undefined references to `testing::internal::GetWithoutMatchers()' follow
CMakeFiles/run-tests.dir/integration/handler_spec_test.cpp.o: In function `testing::internal::FunctionMocker<void (YAML::Mark const&)>::UntypedPerformAction(void const*, void*) const':
handler_spec_test.cpp:(.text._ZNK7testing8internal14FunctionMockerIFvRKN4YAML4MarkEEE20UntypedPerformActionEPKvPv[_ZNK7testing8internal14FunctionMockerIFvRKN4YAML4MarkEEE20UntypedPerformActionEPKvPv]+0x9e): undefined reference to `testing::internal::IllegalDoDefault(char const*, int)'
CMakeFiles/run-tests.dir/integration/handler_spec_test.cpp.o: In function `testing::internal::FunctionMocker<void (YAML::Mark const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, YAML::EmitterStyle::value)>::UntypedPerformAction(void const*, void*) const':
handler_spec_test.cpp:(.text._ZNK7testing8internal14FunctionMockerIFvRKN4YAML4MarkERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmNS2_12EmitterStyle5valueEEE20UntypedPerformActionEPKvPv[_ZNK7testing8internal14FunctionMockerIFvRKN4YAML4MarkERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmNS2_12EmitterStyle5valueEEE20UntypedPerformActionEPKvPv]+0xda): undefined reference to `testing::internal::IllegalDoDefault(char const*, int)'
CMakeFiles/run-tests.dir/integration/handler_spec_test.cpp.o: In function `testing::internal::FunctionMocker<void (YAML::Mark const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)>::UntypedPerformAction(void const*, void*) const':
handler_spec_test.cpp:(.text._ZNK7testing8internal14FunctionMockerIFvRKN4YAML4MarkERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmSD_EE20UntypedPerformActionEPKvPv[_ZNK7testing8internal14FunctionMockerIFvRKN4YAML4MarkERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmSD_EE20UntypedPerformActionEPKvPv]+0xd2): undefined reference to `testing::internal::IllegalDoDefault(char const*, int)'
CMakeFiles/run-tests.dir/integration/handler_spec_test.cpp.o: In function `testing::internal::FunctionMocker<void (YAML::Mark const&, unsigned long)>::UntypedPerformAction(void const*, void*) const':
handler_spec_test.cpp:(.text._ZNK7testing8internal14FunctionMockerIFvRKN4YAML4MarkEmEE20UntypedPerformActionEPKvPv[_ZNK7testing8internal14FunctionMockerIFvRKN4YAML4MarkEmEE20UntypedPerformActionEPKvPv]+0xb2): undefined reference to `testing::internal::IllegalDoDefault(char const*, int)'
CMakeFiles/run-tests.dir/integration/handler_spec_test.cpp.o: In function `testing::internal::FunctionMocker<void ()>::UntypedPerformAction(void const*, void*) const':
handler_spec_test.cpp:(.text._ZNK7testing8internal14FunctionMockerIFvvEE20UntypedPerformActionEPKvPv[_ZNK7testing8internal14FunctionMockerIFvvEE20UntypedPerformActionEPKvPv]+0x8b): undefined reference to `testing::internal::IllegalDoDefault(char const*, int)'
CMakeFiles/run-tests.dir/integration/handler_spec_test.cpp.o:handler_spec_test.cpp:(.text._ZNK7testing8internal14FunctionMockerIFvRKN4YAML4MarkERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmSD_EE27UntypedPerformDefaultActionEPvSD_[_ZNK7testing8internal14FunctionMockerIFvRKN4YAML4MarkERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmSD_EE27UntypedPerformDefaultActionEPvSD_]+0x29c): more undefined references to `testing::internal::IllegalDoDefault(char const*, int)' follow
CMakeFiles/run-tests.dir/integration/handler_spec_test.cpp.o: In function `YAML::MockEventHandler::OnSequenceEnd()':
handler_spec_test.cpp:(.text._ZN4YAML16MockEventHandler13OnSequenceEndEv[_ZN4YAML16MockEventHandler13OnSequenceEndEv]+0x25): undefined reference to `testing::internal::UntypedFunctionMockerBase::UntypedInvokeWith(void*)'
CMakeFiles/run-tests.dir/integration/handler_spec_test.cpp.o: In function `YAML::MockEventHandler::OnMapEnd()':
handler_spec_test.cpp:(.text._ZN4YAML16MockEventHandler8OnMapEndEv[_ZN4YAML16MockEventHandler8OnMapEndEv]+0x25): undefined reference to `testing::internal::UntypedFunctionMockerBase::UntypedInvokeWith(void*)'
CMakeFiles/run-tests.dir/integration/handler_spec_test.cpp.o: In function `YAML::MockEventHandler::OnDocumentEnd()':
handler_spec_test.cpp:(.text._ZN4YAML16MockEventHandler13OnDocumentEndEv[_ZN4YAML16MockEventHandler13OnDocumentEndEv]+0x22): undefined reference to `testing::internal::UntypedFunctionMockerBase::UntypedInvokeWith(void*)'
CMakeFiles/run-tests.dir/integration/handler_spec_test.cpp.o: In function `YAML::MockEventHandler::OnDocumentStart(YAML::Mark const&)':
handler_spec_test.cpp:(.text._ZN4YAML16MockEventHandler15OnDocumentStartERKNS_4MarkE[_ZN4YAML16MockEventHandler15OnDocumentStartERKNS_4MarkE]+0x2b): undefined reference to `testing::internal::UntypedFunctionMockerBase::UntypedInvokeWith(void*)'
CMakeFiles/run-tests.dir/integration/handler_spec_test.cpp.o: In function `YAML::MockEventHandler::OnNull(YAML::Mark const&, unsigned long)':
handler_spec_test.cpp:(.text._ZN4YAML16MockEventHandler6OnNullERKNS_4MarkEm[_ZN4YAML16MockEventHandler6OnNullERKNS_4MarkEm]+0x38): undefined reference to `testing::internal::UntypedFunctionMockerBase::UntypedInvokeWith(void*)'
CMakeFiles/run-tests.dir/integration/handler_spec_test.cpp.o:handler_spec_test.cpp:(.text._ZN4YAML16MockEventHandler7OnAliasERKNS_4MarkEm[_ZN4YAML16MockEventHandler7OnAliasERKNS_4MarkEm]+0x38): more undefined references to `testing::internal::UntypedFunctionMockerBase::UntypedInvokeWith(void*)' follow
CMakeFiles/run-tests.dir/integration/handler_spec_test.cpp.o: In function `testing::internal::MockSpec<void (YAML::Mark const&)>::InternalExpectedAt(char const*, int, char const*, char const*)':
handler_spec_test.cpp:(.text._ZN7testing8internal8MockSpecIFvRKN4YAML4MarkEEE18InternalExpectedAtEPKciS9_S9_[_ZN7testing8internal8MockSpecIFvRKN4YAML4MarkEEE18InternalExpectedAtEPKciS9_S9_]+0x485): undefined reference to `testing::Expectation::Expectation(std::shared_ptr<testing::internal::ExpectationBase> const&)'
CMakeFiles/run-tests.dir/integration/handler_spec_test.cpp.o: In function `testing::internal::MockSpec<void (YAML::Mark const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, YAML::EmitterStyle::value)>::InternalExpectedAt(char const*, int, char const*, char const*)':
handler_spec_test.cpp:(.text._ZN7testing8internal8MockSpecIFvRKN4YAML4MarkERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmNS2_12EmitterStyle5valueEEE18InternalExpectedAtEPKciSJ_SJ_[_ZN7testing8internal8MockSpecIFvRKN4YAML4MarkERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmNS2_12EmitterStyle5valueEEE18InternalExpectedAtEPKciSJ_SJ_]+0x52c): undefined reference to `testing::Expectation::Expectation(std::shared_ptr<testing::internal::ExpectationBase> const&)'
CMakeFiles/run-tests.dir/integration/handler_spec_test.cpp.o: In function `testing::internal::MockSpec<void ()>::InternalExpectedAt(char const*, int, char const*, char const*)':
handler_spec_test.cpp:(.text._ZN7testing8internal8MockSpecIFvvEE18InternalExpectedAtEPKciS5_S5_[_ZN7testing8internal8MockSpecIFvvEE18InternalExpectedAtEPKciS5_S5_]+0x43d): undefined reference to `testing::Expectation::Expectation(std::shared_ptr<testing::internal::ExpectationBase> const&)'
CMakeFiles/run-tests.dir/integration/handler_spec_test.cpp.o: In function `testing::internal::MockSpec<void (YAML::Mark const&, unsigned long)>::InternalExpectedAt(char const*, int, char const*, char const*)':
handler_spec_test.cpp:(.text._ZN7testing8internal8MockSpecIFvRKN4YAML4MarkEmEE18InternalExpectedAtEPKciS9_S9_[_ZN7testing8internal8MockSpecIFvRKN4YAML4MarkEmEE18InternalExpectedAtEPKciS9_S9_]+0x4be): undefined reference to `testing::Expectation::Expectation(std::shared_ptr<testing::internal::ExpectationBase> const&)'
CMakeFiles/run-tests.dir/integration/handler_spec_test.cpp.o: In function `testing::internal::MockSpec<void (YAML::Mark const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)>::InternalExpectedAt(char const*, int, char const*, char const*)':
handler_spec_test.cpp:(.text._ZN7testing8internal8MockSpecIFvRKN4YAML4MarkERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmSD_EE18InternalExpectedAtEPKciSH_SH_[_ZN7testing8internal8MockSpecIFvRKN4YAML4MarkERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmSD_EE18InternalExpectedAtEPKciSH_SH_]+0x52c): undefined reference to `testing::Expectation::Expectation(std::shared_ptr<testing::internal::ExpectationBase> const&)'
CMakeFiles/run-tests.dir/integration/handler_test.cpp.o: In function `YAML::(anonymous namespace)::HandlerTest_PlainScalarStartingWithQuestionMark_Test::TestBody()':
handler_test.cpp:(.text+0x9f2): undefined reference to `testing::internal::GetWithoutMatchers()'
handler_test.cpp:(.text+0xaa3): undefined reference to `testing::internal::GetWithoutMatchers()'
handler_test.cpp:(.text+0xb8a): undefined reference to `testing::internal::GetWithoutMatchers()'
handler_test.cpp:(.text+0xc71): undefined reference to `testing::internal::GetWithoutMatchers()'
handler_test.cpp:(.text+0xd22): undefined reference to `testing::internal::GetWithoutMatchers()'
CMakeFiles/run-tests.dir/integration/handler_test.cpp.o:handler_test.cpp:(.text+0xd5c): more undefined references to `testing::internal::GetWithoutMatchers()' follow
collect2: error: ld returned 1 exit status
test/CMakeFiles/run-tests.dir/build.make:356: recipe for target 'test/run-tests' failed
make[2]: *** [test/run-tests] Error 1
CMakeFiles/Makefile2:221: recipe for target 'test/CMakeFiles/run-tests.dir/all' failed
make[1]: *** [test/CMakeFiles/run-tests.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2

我太笨了,无法从错误代码中得到任何有用的信息。我需要帮助QAQ

答案1

为了向自己证明问题的根源,在第 24 行CMakeLists.txt暂时地将“启用测试”选项更改为关闭并重试:

option(YAML_CPP_BUILD_TESTS "Enable testing" ON)

if(YAML_CPP_BUILD_TESTS) enable_testing() add_subdirectory(test) endif()

请注意,yaml-cpp 使用“谷歌测试“ A

合并以前独立的 GoogleTest 和 GoogleMock 项目

因此,要么您的路径中存在另一个版本的 Google Test,要么 yaml-cpp 项目未在其树中自动构建 Google Test 套件。因此,请确定https://github.com/jbeder/yaml-cpp/tree/master/test 并且子组件正在构建中。

相关内容