编译gtest和gmock示例

时间:2018-03-16 02:53:12

标签: c++ googletest googlemock

我有一本书,现代C ++编程与测试驱动开发,我想从本书构建示例,即时通讯使用谷歌模拟1.6.0和谷歌测试1.6.0我得到以下错误,当我尝试构建

请帮忙!!

[ 14%] Linking CXX executable test
CMakeFiles/test.dir/CharUtilTest.cpp.o: In function `AChar_IsAVowelForSixSpecificLetters_Test::TestBody()':
CharUtilTest.cpp:(.text+0x78): undefined reference to `testing::internal::GetBoolAssertionFailureMessage(testing::AssertionResult const&, char const*, char const*, char const*)'
CharUtilTest.cpp:(.text+0x160): undefined reference to `testing::internal::GetBoolAssertionFailureMessage(testing::AssertionResult const&, char const*, char const*, char const*)'
CharUtilTest.cpp:(.text+0x248): undefined reference to `testing::internal::GetBoolAssertionFailureMessage(testing::AssertionResult const&, char const*, char const*, char const*)'
CharUtilTest.cpp:(.text+0x330): undefined reference to `testing::internal::GetBoolAssertionFailureMessage(testing::AssertionResult const&, char const*, char const*, char const*)'
CharUtilTest.cpp:(.text+0x418): undefined reference to `testing::internal::GetBoolAssertionFailureMessage(testing::AssertionResult const&, char const*, char const*, char const*)'
CMakeFiles/test.dir/CharUtilTest.cpp.o:CharUtilTest.cpp:(.text+0x500): more undefined references to `testing::internal::GetBoolAssertionFailureMessage(testing::AssertionResult const&, char const*, char const*, char const*)' follow
CMakeFiles/test.dir/CharUtilTest.cpp.o: In function `__static_initialization_and_destruction_0(int, int)':
CharUtilTest.cpp:(.text+0x18fc): undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
CharUtilTest.cpp:(.text+0x1954): undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
CharUtilTest.cpp:(.text+0x19ac): undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
CharUtilTest.cpp:(.text+0x1a04): undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
CharUtilTest.cpp:(.text+0x1a5c): undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
CMakeFiles/test.dir/CharUtilTest.cpp.o:CharUtilTest.cpp:(.text+0x1ab4): more undefined references to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)' follow
/home/matthew/googlemock-release-1.6.0/mybuild/libgmock.a(gmock-all.cc.o): In function `testing::internal::Log(testing::internal::LogSeverity, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)':
gmock-all.cc:(.text+0xdc1): undefined reference to `testing::internal::GetCurrentOsStackTraceExceptTop(testing::UnitTest*, int)'
/home/matthew/googlemock-release-1.6.0/mybuild/libgmock.a(gmock-all.cc.o): In function `testing::internal::ParseGoogleMockFlagValue(char const*, char const*, bool)':
gmock-all.cc:(.text+0x44f2): undefined reference to `testing::internal::String::Format(char const*, ...)'
/home/matthew/googlemock-release-1.6.0/mybuild/libgmock.a(gmock-all.cc.o): In function `testing::internal::String::operator==(char const*) const':
gmock-all.cc:(.text._ZNK7testing8internal6StringeqEPKc[_ZNK7testing8internal6StringeqEPKc]+0x42): undefined reference to `testing::internal::String::Compare(testing::internal::String const&) const'
/home/matthew/googlemock-release-1.6.0/mybuild/libgmock.a(gmock-all.cc.o): In function `testing::Message::operator<<(wchar_t*)':
gmock-all.cc:(.text._ZN7testing7MessagelsEPw[_ZN7testing7MessagelsEPw]+0x2f): undefined reference to `testing::internal::String::ShowWideCString(wchar_t const*)'
collect2: error: ld returned 1 exit status
CMakeFiles/test.dir/build.make:158: recipe for target 'test' failed
make[2]: *** [test] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/test.dir/all' failed
make[1]: *** [CMakeFiles/test.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

matthew@Matthew:~/code/c2/40/build$ make VERBOSE=1
/usr/local/bin/cmake -H/home/matthew/code/c2/40 -B/home/matthew/code/c2/40/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/local/bin/cmake -E cmake_progress_start /home/matthew/code/c2/40/build/CMakeFiles /home/matthew/code/c2/40/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/matthew/code/c2/40/build'
make -f CMakeFiles/test.dir/build.make CMakeFiles/test.dir/depend
make[2]: Entering directory '/home/matthew/code/c2/40/build'
cd /home/matthew/code/c2/40/build && /usr/local/bin/cmake -E cmake_depends "Unix Makefiles" /home/matthew/code/c2/40 /home/matthew/code/c2/40 /home/matthew/code/c2/40/build /home/matthew/code/c2/40/build /home/matthew/code/c2/40/build/CMakeFiles/test.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/matthew/code/c2/40/build'
make -f CMakeFiles/test.dir/build.make CMakeFiles/test.dir/build
make[2]: Entering directory '/home/matthew/code/c2/40/build'
[ 14%] Linking CXX executable test
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/test.dir/link.txt --verbose=1
/usr/bin/c++   -Wall  -rdynamic CMakeFiles/test.dir/CharUtilTest.cpp.o CMakeFiles/test.dir/SoundexTest.cpp.o CMakeFiles/test.dir/StringUtilTest.cpp.o CMakeFiles/test.dir/main.cpp.o CMakeFiles/test.dir/CharUtil.cpp.o CMakeFiles/test.dir/StringUtil.cpp.o  -o test  -L/home/matthew/googletest-release-1.8.0/googlemock/build  -L/home/matthew/googletest-release-1.8.0/googlemock/gtest/mybuild -Wl,-rpath,/home/matthew/googletest-release-1.8.0/googlemock/build:/home/matthew/googletest-release-1.8.0/googlemock/gtest/mybuild -lpthread -lgmock -lgtest 
/usr/bin/ld: cannot find -lgmock
collect2: error: ld returned 1 exit status
CMakeFiles/test.dir/build.make:158: recipe for target 'test' failed
make[2]: *** [test] Error 1
make[2]: Leaving directory '/home/matthew/code/c2/40/build'
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/test.dir/all' failed
make[1]: *** [CMakeFiles/test.dir/all] Error 2
make[1]: Leaving directory '/home/matthew/code/c2/40/build'
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

0 个答案:

没有答案