- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在 Windows 中使用 Qt Creator
进行谷歌模拟测试,但结果出现了很多不同的 undefined reference
错误。
我在 Linux 上试过了,它工作正常。我不知道在 Windows 方面我是否对 gmock
进行了错误设置。
这是在 MOCK_CONST_METHOD2
、MOCK_METHOD2
、MOCK_METHOD1
和前两个 EXPECT_CALL
上存在问题的代码。还有关于 gmock
头文件的问题。
main.cpp
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "mail_service.hpp"
#include "warehouse.hpp"
#include "order.hpp"
using ::testing::Return;
using ::testing::_; // Matcher for parameters
/** \brief Mock for the warehouse interface.
* \author David Stutz
*/
class MockWarehouse : public Warehouse
{
public:
// see https://github.com/google/googletest/blob/master/googlemock/docs/ForDummies.md
MOCK_CONST_METHOD2(hasInventory, bool(int, std::string));
MOCK_METHOD2(remove, void(int, std::string));
};
/** \brief Mock for the mail service interface.
* \author David Stutz
*/
class MockMailService : public MailService
{
public:
MockMailService()
{
}
MOCK_METHOD1(send, void(std::string));
};
TEST(OrderTest, Fill)
{
MockWarehouse warehouse;
std::shared_ptr<MockMailService> mailService = std::make_shared<MockMailService>();
Order order(50, "Talisker");
order.setMailService(mailService);
EXPECT_CALL(warehouse, hasInventory(50, "Talisker"))
.Times(1)
.WillOnce(Return(true));
EXPECT_CALL(warehouse, remove(50, "Talisker"))
.Times(1);
EXPECT_CALL(*mailService, send(_)) // Not making assumptions on the message send ...
.Times(1);
ASSERT_TRUE(order.fill(warehouse));
}
/** \brief Main test entrance point.
* \param[in] argc
* \param[in] argv
*/
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
标题
mail_service.hpp
#ifndef MAIL_SERVICE_HPP
#define MAIL_SERVICE_HPP
class MailService
{
public:
/** \brief Send a mial.
* \param[in] message message to send
*/
virtual void send(std::string message) = 0;
};
#endif /* MAIL_SERVICE_HPP */
order.hpp
#ifndef ORDER_HPP
#define ORDER_HPP
#include <string>
#include <memory>
#include "warehouse.hpp"
#include "mail_service.hpp"
/** \brief An order of a product with quantity. */
class Order
{
public:
/** \brief Constructor.
* \param[in] quantity quantity requested
* \param[in] product product name requested
*/
Order(int quantity, std::string product)
{
this->quantity = quantity;
this->product = product;
}
/** \brief Set the mail service to use.
* \param[in] mailService the mail service to attach
*/
void setMailService(std::shared_ptr<MailService> mailService)
{
this->mailService = mailService;
}
/** \brief Fill the order given the warehouse.
* \param[in] warehouse the warehouse to use
* \return whether the operation was successful
*/
bool fill(Warehouse &warehouse)
{
if (warehouse.hasInventory(quantity, product))
{
// ...
warehouse.remove(quantity, product);
this->mailService->send("Order filled.");
return true;
}
else
{
// ...
this->mailService->send("Order not filled.");
return false;
}
}
private:
/** \brief Product name. */
std::string product;
/** \brief Quantity requested. */
int quantity;
/** \brief Mail service to use. */
std::shared_ptr<MailService> mailService;
};
#endif /* ORDER_HPP */
仓库.hpp
#ifndef WAREHOUSE_HPP
#define WAREHOUSE_HPP
#include <string>
/** \brief Warehouse interface. This interface is one of the collaborators of our SUT.
class Warehouse
{
public:
/** \brief Check whether the product in the given quantity is on stock.
* \param[in] quantity quantity requested
* \param[in] product product name
* \return whether the warehouse has the product on stock for the given quantity
*/
virtual bool hasInventory(int quantity, std::string product) const = 0;
/** \brief Remove the given quantity of the product from the warehouse.
* \param[in] quantity quantity to remove
* \param[in] product product name to remove
*/
virtual void remove(int quantity, std::string product) = 0;
};
#endif /* WAREHOUSE_HPP */
这是 .pro 文件
CONFIG += console c++14
INCLUDEPATH += "google/gmock/include/"
INCLUDEPATH += "google/gmock/"
INCLUDEPATH += "google/gtest/include/"
INCLUDEPATH += "google/gtest/src/"
INCLUDEPATH += "google/gtest/"
INCLUDEPATH += "google/"
INCLUDEPATH += "../../"
SOURCES += \
order.cpp \
google/gtest/src/gtest.cc \
google/gtest/src/gtest-all.cc \
google/gtest/src/gtest-death-test.cc \
google/gtest/src/gtest-filepath.cc \
google/gtest/src/gtest-port.cc \
google/gtest/src/gtest-printers.cc \
google/gtest/src/gtest-test-part.cc \
google/gtest/src/gtest-typed-test.cc
HEADERS += \
mail_service.hpp \
order.hpp \
warehouse.hpp
这是编译输出错误:
10:53:25: Running steps for project GoogleMockTest2...
10:53:25: Configuration unchanged, skipping qmake step.
10:53:27: Starting: "C:\Qt\Qt5.9.3\Tools\mingw530_32\bin\mingw32-make.exe"
C:\Qt\Qt5.9.3\5.9.3\mingw53_32\bin\qmake.exe -o Makefile ..\GoogleMockTest2\GoogleMockTest2.pro -spec win32-g++ "CONFIG+=debug" "CONFIG+=qml_debug"
C:/Qt/Qt5.9.3/Tools/mingw530_32/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory 'C:/Users/PB9N0052/Documents/build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug'
g++ -c -fno-keep-inline-dllexport -g -std=gnu++1y -Wextra -Wall -W -fexceptions -mthreads -DUNICODE -D_UNICODE -DQT_QML_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I..\GoogleMockTest2 -I. -I..\GoogleMockTest2\google\googlemock\include -I..\GoogleMockTest2\google\googlemock -I..\GoogleMockTest2\google\googletest\include -I..\GoogleMockTest2\google\googletest\src -I..\GoogleMockTest2\google\googletest -I..\GoogleMockTest2\google -I..\..\..\PB9N0052 -I..\..\..\..\Qt\Qt5.9.3\5.9.3\mingw53_32\include -I..\..\..\..\Qt\Qt5.9.3\5.9.3\mingw53_32\include\QtGui -I..\..\..\..\Qt\Qt5.9.3\5.9.3\mingw53_32\include\QtANGLE -I..\..\..\..\Qt\Qt5.9.3\5.9.3\mingw53_32\include\QtCore -Idebug -I..\..\..\..\Qt\Qt5.9.3\5.9.3\mingw53_32\mkspecs\win32-g++ -o debug\warehouse.o ..\GoogleMockTest2\warehouse.cpp
g++ -c -fno-keep-inline-dllexport -g -std=gnu++1y -Wextra -Wall -W -fexceptions -mthreads -DUNICODE -D_UNICODE -DQT_QML_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I..\GoogleMockTest2 -I. -I..\GoogleMockTest2\google\googlemock\include -I..\GoogleMockTest2\google\googlemock -I..\GoogleMockTest2\google\googletest\include -I..\GoogleMockTest2\google\googletest\src -I..\GoogleMockTest2\google\googletest -I..\GoogleMockTest2\google -I..\..\..\PB9N0052 -I..\..\..\..\Qt\Qt5.9.3\5.9.3\mingw53_32\include -I..\..\..\..\Qt\Qt5.9.3\5.9.3\mingw53_32\include\QtGui -I..\..\..\..\Qt\Qt5.9.3\5.9.3\mingw53_32\include\QtANGLE -I..\..\..\..\Qt\Qt5.9.3\5.9.3\mingw53_32\include\QtCore -Idebug -I..\..\..\..\Qt\Qt5.9.3\5.9.3\mingw53_32\mkspecs\win32-g++ -o debug\mail_service.o ..\GoogleMockTest2\mail_service.cpp
g++ -Wl,-subsystem,console -mthreads -o debug\GoogleMockTest2.exe debug/order.o debug/gtest-all.o debug/warehouse.o debug/mail_service.o -LC:\Qt\Qt5.9.3\5.9.3\mingw53_32\lib C:\Qt\Qt5.9.3\5.9.3\mingw53_32\lib\libQt5Guid.a C:\Qt\Qt5.9.3\5.9.3\mingw53_32\lib\libQt5Cored.a
debug/order.o: In function `ZN19OrderTest_Fill_Test8TestBodyEv':
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/order.cpp:44: undefined reference to `testing::Matcher<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::Matcher(char const*)'
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1416: undefined reference to `testing::Mock::UnregisterLocked(testing::internal::UntypedFunctionMockerBase*)'
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1418: undefined reference to `testing::internal::UntypedFunctionMockerBase::~UntypedFunctionMockerBase()'
debug/order.o: In function `ZN7testing8internal18FunctionMockerBaseIFvNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEED1Ev':
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1414: undefined reference to `testing::internal::g_gmock_mutex'
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1415: undefined reference to `testing::internal::UntypedFunctionMockerBase::VerifyAndClearExpectationsLocked()'
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1416: undefined reference to `testing::Mock::UnregisterLocked(testing::internal::UntypedFunctionMockerBase*)'
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1418: undefined reference to `testing::internal::UntypedFunctionMockerBase::~UntypedFunctionMockerBase()'
debug/order.o: In function `ZN7testing8internal18FunctionMockerBaseIFbiNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEC2Ev':
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1407: undefined reference to `testing::internal::UntypedFunctionMockerBase::UntypedFunctionMockerBase()'
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1407: undefined reference to `testing::internal::UntypedFunctionMockerBase::~UntypedFunctionMockerBase()'
debug/order.o: In function `ZN7testing8internal18FunctionMockerBaseIFbiNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEED2Ev':
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1414: undefined reference to `testing::internal::g_gmock_mutex'
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1415: undefined reference to `testing::internal::UntypedFunctionMockerBase::VerifyAndClearExpectationsLocked()'
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1416: undefined reference to `testing::Mock::UnregisterLocked(testing::internal::UntypedFunctionMockerBase*)'
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1418: undefined reference to `testing::internal::UntypedFunctionMockerBase::~UntypedFunctionMockerBase()'
debug/order.o: In function `ZN7testing8internal18FunctionMockerBaseIFbiNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEED1Ev':
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1414: undefined reference to `testing::internal::g_gmock_mutex'
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1415: undefined reference to `testing::internal::UntypedFunctionMockerBase::VerifyAndClearExpectationsLocked()'
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1416: undefined reference to `testing::Mock::UnregisterLocked(testing::internal::UntypedFunctionMockerBase*)'
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1418: undefined reference to `testing::internal::UntypedFunctionMockerBase::~UntypedFunctionMockerBase()'
debug/order.o: In function `ZN7testing8internal18FunctionMockerBaseIFviNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEC2Ev':
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1407: undefined reference to `testing::internal::UntypedFunctionMockerBase::UntypedFunctionMockerBase()'
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1407: undefined reference to `testing::internal::UntypedFunctionMockerBase::~UntypedFunctionMockerBase()'
debug/order.o: In function `ZN7testing8internal18FunctionMockerBaseIFviNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEED2Ev':
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1414: undefined reference to `testing::internal::g_gmock_mutex'
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1415: undefined reference to `testing::internal::UntypedFunctionMockerBase::VerifyAndClearExpectationsLocked()'
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1416: undefined reference to `testing::Mock::UnregisterLocked(testing::internal::UntypedFunctionMockerBase*)'
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1418: undefined reference to `testing::internal::UntypedFunctionMockerBase::~UntypedFunctionMockerBase()'
debug/order.o: In function `ZN7testing8internal18FunctionMockerBaseIFviNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEED1Ev':
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1414: undefined reference to `testing::internal::g_gmock_mutex'
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1415: undefined reference to `testing::internal::UntypedFunctionMockerBase::VerifyAndClearExpectationsLocked()'
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1416: undefined reference to `testing::Mock::UnregisterLocked(testing::internal::UntypedFunctionMockerBase*)'
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1418: undefined reference to `testing::internal::UntypedFunctionMockerBase::~UntypedFunctionMockerBase()'
debug/order.o: In function `ZN7testing8internal8MockSpecIFbiNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE18InternalExpectedAtEPKciSB_SB_':
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1271: undefined reference to `testing::internal::LogWithLocation(testing::internal::LogSeverity, char const*, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
debug/order.o: In function `ZN7testing8internal16TypedExpectationIFbiNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE5TimesEi':
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:932: undefined reference to `testing::Exactly(int)'
debug/order.o: In function `ZN7testing8internal16TypedExpectationIFbiNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE8WillOnceERKNS_6ActionIS8_EE':
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1002: undefined reference to `testing::Exactly(int)'
debug/order.o: In function `ZN7testing8internal8MockSpecIFviNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE18InternalExpectedAtEPKciSB_SB_':
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1271: undefined reference to `testing::internal::LogWithLocation(testing::internal::LogSeverity, char const*, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
debug/order.o: In function `ZN7testing8internal16TypedExpectationIFviNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE5TimesEi':
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:932: undefined reference to `testing::Exactly(int)'
debug/order.o: In function `ZN7testing8internal8MockSpecIFvNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE18InternalExpectedAtEPKciSB_SB_':
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1271: undefined reference to `testing::internal::LogWithLocation(testing::internal::LogSeverity, char const*, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
debug/order.o: In function `ZN7testing8internal16TypedExpectationIFvNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE5TimesEi':
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:932: undefined reference to `testing::Exactly(int)'
debug/order.o: In function `ZN7testing8internal18FunctionMockerBaseIFbiNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE10InvokeWithERKSt5tupleIJiS7_EE':
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1529: undefined reference to `testing::internal::UntypedFunctionMockerBase::UntypedInvokeWith(void const*)'
debug/order.o: In function `ZN7testing8internal18FunctionMockerBaseIFviNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE10InvokeWithERKSt5tupleIJiS7_EE':
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1529: undefined reference to `testing::internal::UntypedFunctionMockerBase::UntypedInvokeWith(void const*)'
debug/order.o: In function `ZN7testing8internal18FunctionMockerBaseIFvNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE25ClearDefaultActionsLockedEv':
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1560: undefined reference to `testing::Expectation::~Expectation()'
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1551: undefined reference to `testing::internal::UntypedFunctionMockerBase::MockObject() const'
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1551: undefined reference to `testing::Mock::RegisterUseByOnCallOrExpectCall(void const*, char const*, int)'
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1558: undefined reference to `testing::internal::g_gmock_implicit_sequence'
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1560: undefined reference to `testing::Expectation::Expectation(testing::internal::linked_ptr<testing::internal::ExpectationBase> const&)'
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1560: undefined reference to `testing::Sequence::AddExpectation(testing::Expectation const&) const'
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1560: undefined reference to `testing::Expectation::~Expectation()'
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1560: undefined reference to `testing::Expectation::~Expectation()'
debug/order.o: In function `ZN7testing8internal16TypedExpectationIFvNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE5TimesERKNS_11CardinalityE':
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:926: undefined reference to `testing::internal::ExpectationBase::UntypedTimes(testing::Cardinality const&)'
debug/order.o: In function `ZN7testing8internal16TypedExpectationIFbiNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEC1EPNS0_18FunctionMockerBaseIS8_EEPKciRKS7_RKSt5tupleIJNS_7MatcherIiEENSI_IS7_EEEE':
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:894: undefined reference to `testing::internal::ExpectationBase::ExpectationBase(char const*, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:894: undefined reference to `testing::internal::ExpectationBase::~ExpectationBase()'
debug/order.o: In function `ZN7testing8internal16TypedExpectationIFviNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEC1EPNS0_18FunctionMockerBaseIS8_EEPKciRKS7_RKSt5tupleIJNS_7MatcherIiEENSI_IS7_EEEE':
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:899: undefined reference to `testing::internal::ExpectationBase::CheckActionCountIfNotDone() const'
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:904: undefined reference to `testing::internal::ExpectationBase::~ExpectationBase()'
debug/order.o: In function `ZN7testing8internal16TypedExpectationIFbiNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE9GetHandleEv':
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1077: undefined reference to `testing::internal::UntypedFunctionMockerBase::GetHandleOf(testing::internal::ExpectationBase*)'
debug/order.o: In function `ZNK7testing8internal18FunctionMockerBaseIFvNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE32UntypedDescribeUninterestingCallEPKvPSo':
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1603: undefined reference to `testing::internal::UntypedFunctionMockerBase::Name() const'
debug/order.o: In function `ZN7testing8internal18FunctionMockerBaseIFvNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE30UntypedFindMatchingExpectationEPKvPSB_PbPSoSE_':
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1630: undefined reference to `testing::internal::g_gmock_mutex'
debug/order.o: In function `ZNK7testing8internal18FunctionMockerBaseIFviNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE32UntypedDescribeUninterestingCallEPKvPSo':
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1603: undefined reference to `testing::internal::UntypedFunctionMockerBase::Name() const'
debug/order.o: In function `ZN7testing8internal18FunctionMockerBaseIFviNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE30UntypedFindMatchingExpectationEPKvPSB_PbPSoSE_':
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1630: undefined reference to `testing::internal::g_gmock_mutex'
debug/order.o: In function `ZNK7testing8internal18FunctionMockerBaseIFbiNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE32UntypedDescribeUninterestingCallEPKvPSo':
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1603: undefined reference to `testing::internal::UntypedFunctionMockerBase::Name() const'
debug/order.o: In function `ZN7testing8internal18FunctionMockerBaseIFbiNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE30UntypedFindMatchingExpectationEPKvPSB_PbPSoSE_':
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1630: undefined reference to `testing::internal::g_gmock_mutex'
debug/order.o: In function `ZNK7testing8internal18FunctionMockerBaseIFvNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE29FindMatchingExpectationLockedERKSt5tupleIJS7_EE':
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1661: undefined reference to `testing::internal::g_gmock_mutex'
debug/order.o: In function `ZNK7testing8internal18FunctionMockerBaseIFvNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE33FormatUnexpectedCallMessageLockedERKSt5tupleIJS7_EEPSoSE_':
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1110: undefined reference to `testing::internal::g_gmock_mutex'
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1128: undefined reference to `testing::internal::ExpectationBase::AllPrerequisitesAreSatisfied() const'
C:\Users\PB9N0052\Documents\build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug/../GoogleMockTest2/google/gmock/include/gmock/gmock-spec-builders.h:1133: undefined reference to `testing::internal::ExpectationBase::FindUnsatisfiedPrerequisites(testing::ExpectationSet*) const'
collect2.exe: error: ld returned 1 exit status
mingw32-make[1]: *** [debug\GoogleMockTest2.exe] Error 1
mingw32-make: *** [debug] Error 2
Makefile.Debug:74: recipe for target 'debug\GoogleMockTest2.exe' failed
mingw32-make[1]: Leaving directory 'C:/Users/PB9N0052/Documents/build-GoogleMockTest2-Desktop_Qt_5_9_3_MinGW_32bit-Debug'
Makefile:36: recipe for target 'debug' failed
10:53:32: The process "C:\Qt\Qt5.9.3\Tools\mingw530_32\bin\mingw32-make.exe" exited with code 2.
Error while building/deploying project GoogleMockTest2 (kit: Desktop Qt 5.9.3 MinGW 32bit)
When executing step "Make"
10:53:32: Elapsed time: 00:07.
最佳答案
也许您忘记在源代码中添加 gmock 的“.cc”文件。因为在你的.pro文件中,你只添加了gtest的“.cc”文件。
我通常做的是,“添加现有文件”,然后查找 gmock 的 src 文件夹。并添加 .cc 文件。
喜欢这个示例:
SOURCES += \
../calculator.cpp \
../button.cpp \
main.cpp \
gtest/src/gtest.cc \
gtest/src/gtest-all.cc \
gtest/src/gtest-death-test.cc \
gtest/src/gtest-filepath.cc \
gtest/src/gtest-port.cc \
gtest/src/gtest-printers.cc \
gtest/src/gtest-test-part.cc \
gtest/src/gtest-typed-test.cc \
gmock/src/gmock-spec-builders.cc \
gmock/src/gmock-matchers.cc \
gmock/src/gmock-internal-utils.cc \
gmock/src/gmock-cardinalities.cc \
gmock/src/gmock-all.cc \
gmock/src/gmock.cc
关于c++ - Qt 中的 GMock 和 undefined reference 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57036608/
我正在使用 Qt 语言学家翻译一个 ui 文件。我使用 lupdate 获取了它的 ts 文件,并翻译了这些单词和短语。现在我想将它添加到我的代码中,但我从它的教程中发现我似乎必须将 tr() 添加到
我想在 Qt Creator 中创建下面的简单控制台应用程序: #include int main(int argc, char* argv[]) { std::cout #include
我想将 libQtGui.so.4 libQtNetwork.so.4 和 libQtCore.so.4 包含在与我的应用程序所在的目录相同的目录中。我如何让 Qt 理解这一点? y 目的是拥有一个使
我有一个充满 QPushButtons 和 QLabels 以及各种其他有趣的 QWidget 的窗口,所有这些都使用各种 QLayout 对象动态布局...而我想做的是偶尔制作一些这些小部件变得不可
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎与 help center 中定义的范围内的编程无关。 . 关闭 7 年前。 Improve
我想知道 Qt 是否将下面代码的“版本 1”之类的东西放在堆上?在版本 1 中,Qt 会将 dirStuff 放在堆栈上还是堆上?我问是因为我有一种感觉,Java 将所有数据结构放在堆上......不
这个问题是关于 Qt Installer Framework 2.0 版的。 在这一点上,使用 Qt 安装程序框架的人都知道,如果不进行自定义,您根本无法通过安装程序覆盖现有安装。这样做显然是为了解决
关闭。这个问题是off-topic .它目前不接受答案。 想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。 8年前关闭。 Improve this q
因为我在我的计算机上安装了 Qt 4.8.4 和 Qt 5.1,所以我遇到了问题。 当只有 Qt 4.8.4 存在时,一切都很好。 当我添加 Qt 5.1 时,这个工作正常,但 Qt 4.8.4 给了
我无法在我的 Ubuntu 12 中安装更多软件包。我尝试了 apt-get install -f ,以及许多其他类似的技巧,但在找到解决方案方面没有进展。 这是属于 Qt 的损坏包: 以下包具有未满
我正在尝试使用 Virtual Box 中的 Ubuntu 机器复制我们目前在物理 Ubuntu 服务器上运行的应用程序。它是一个 QT 应用程序,但在服务器上我们使用 NPM 的 pm2 运行它。安
问题: Qt Creator 是用 Qt Creator 构建的吗? 同样,Qt Designer 是用 Qt Designer 构建的吗? 顺便说一句,为什么有两个 Qt IDE?他们是竞争对手吗?
当我使用 QWidget设计用户界面时,我总是对它的大小属性有点困惑。有size policy , geometry和 hintSize . 我只知道size policy之间的关系和 hintSiz
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我想知道是否有一种很好的方法可以让用户像 LabView 一样创建节点图(有限制)。 像这样的东西: 我见过http://www.pyqtgraph.org/ ,这似乎有类似的东西,我确实打算使用 P
在 Qt 中是否有一种跨平台的方式来获得用户喜欢的固定宽度和比例字体? 例如,在 cocoa 中,有 NSFont *proportional = [NSFont userFontOfSize:12.
我想使用 Qt 和 C++ 制作这样的交互式图表:http://jsxgraph.uni-bayreuth.de/wiki/index.php/Cubic_spline_interpolation 关
我正在编写一个嵌入式设备屏幕的模拟(其中包含主 QWidget 顶部的自定义小部件),虽然屏幕的原始尺寸是 800x600,但我希望能够按比例放大和缩小它拖动窗口的角。如果不使用网格布局和担架(不会向
在下面的示例中,我是否必须从堆中删除对象?如果是的话,怎么办? #include #include #include #include #include int main(int argc,
来自 Web 开发背景,我现在进入 QT 应用程序开发。 使用 QFonts 我已经看到我显然只有两个选择,在 QT 中定义字体大小;按像素大小或点大小。 在制作网页布局时,我习惯于以相对方式定义所有
我是一名优秀的程序员,十分优秀!