Na szybko chciałem zapytać
Instalowałem gmock i gtest przez apt-get google-mock i libgtest-dev
teraz chcąc coś skompilować:
g++ my_test.cpp -std=c++11 -lgtest -lgtest_main -lgmock -pthread
Miał ktoś już z czymś takim do czynienia?
/tmp/ccdgt5dw.o: In function `testing::internal::FunctionMockerBase<double ()>::InvokeWith(std::tuple<> const&)':
prog.cpp:(.text._ZN7testing8internal18FunctionMockerBaseIFdvEE10InvokeWithERKSt5tupleIJEE[_ZN7testing8internal18FunctionMockerBaseIFdvEE10InvokeWithERKSt5tupleIJEE]+0x20): undefined reference to `testing::internal::UntypedFunctionMockerBase::UntypedInvokeWith(void const*)'
/tmp/ccdgt5dw.o: In function `testing::internal::FunctionMockerBase<void (WeatherStation::Direction*, double*)>::InvokeWith(std::tuple<WeatherStation::Direction*, double*> const&)':
prog.cpp:(.text._ZN7testing8internal18FunctionMockerBaseIFvPN14WeatherStation9DirectionEPdEE10InvokeWithERKSt5tupleIJS4_S5_EE[_ZN7testing8internal18FunctionMockerBaseIFvPN14WeatherStation9DirectionEPdEE10InvokeWithERKSt5tupleIJS4_S5_EE]+0x1f): undefined reference to `testing::internal::UntypedFunctionMockerBase::UntypedInvokeWith(void const*)'
/tmp/ccdgt5dw.o: In function `testing::internal::FunctionMockerBase<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > (WeatherStation::Outlook)>::InvokeWith(std::tuple<WeatherStation::Outlook> const&)':
prog.cpp:(.text._ZN7testing8internal18FunctionMockerBaseIFNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN14WeatherStation7OutlookEEE10InvokeWithERKSt5tupleIJS9_EE[_ZN7testing8internal18FunctionMockerBaseIFNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN14WeatherStation7OutlookEEE10InvokeWithERKSt5tupleIJS9_EE]+0x24): undefined reference to `testing::internal::UntypedFunctionMockerBase::UntypedInvokeWith(void const*)'
collect2: error: ld returned 1 exit status
przy prostym takim czymś, już normalnie się kompiluje.
#include <gtest/gtest.h>
TEST(test, subtest) {
ASSERT_EQ(1, 1);
}
int main(int argc, char **argv) {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
problem dopiero się pojawia przy pisaniu mocków