Google Mock linking errors

13,137 views
Skip to first unread message

Roey Chen

unread,
Jul 29, 2013, 9:20:56 AM7/29/13
to googl...@googlegroups.com
I'm getting a lot of errors while trying to build an example test,
any help is appreciated, Thanks.

Here's the code:

#include <gmock/gmock.h>           
#include <gtest/gtest.h>    

class Foo {
  public:
    Foo() {}
    virtual int Get() = 0;
};

class MockFoo : Foo {
  public:
    MOCK_METHOD0(Get, int());
};

using ::testing::Return;

TEST(MockTest, MockFoo) {
  MockFoo foo;
  EXPECT_CALL(foo, Get())
    .Times(1)
    .WillOnce(Return(5));
  foo.Get();
}

int main(int argc, char* argv[]) {
  ::testing::InitGoogleTest(&argc,argv);
  return RUN_ALL_TESTS();
}


Here's what I'm getting when trying to build the test:

# g++ -c my_test.cpp 
# g++  -lpthread -lgtest my_test.o -o my_test

my_test.o: In function `testing::internal::Assert(bool, char const*, int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
my_test.cpp:(.text._ZN7testing8internal6AssertEbPKciRKSs[testing::internal::Assert(bool, char const*, int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)]+0x25): undefined reference to `testing::internal::GetFailureReporter()'                                                                          
my_test.o: In function `testing::internal::Expect(bool, char const*, int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':            
my_test.cpp:(.text._ZN7testing8internal6ExpectEbPKciRKSs[testing::internal::Expect(bool, char const*, int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)]+0x25): undefined reference to `testing::internal::GetFailureReporter()'                                                                          
my_test.o: In function `testing::internal::ExpectationBase::is_retired() const':                                                                                      
my_test.cpp:(.text._ZNK7testing8internal15ExpectationBase10is_retiredEv[testing::internal::ExpectationBase::is_retired() const]+0xd): undefined reference to `testing::internal::g_gmock_mutex'                                                                                                                                             
my_test.o: In function `testing::internal::ExpectationBase::Retire()':                                                                                                
my_test.cpp:(.text._ZN7testing8internal15ExpectationBase6RetireEv[testing::internal::ExpectationBase::Retire()]+0xd): undefined reference to `testing::internal::g_gmock_mutex'                                                                                                                                                             
my_test.o: In function `testing::internal::ExpectationBase::IsSaturated() const':                                                                                     
my_test.cpp:(.text._ZNK7testing8internal15ExpectationBase11IsSaturatedEv[testing::internal::ExpectationBase::IsSaturated() const]+0xe): undefined reference to `testing::internal::g_gmock_mutex'                                                                                                                                           
my_test.o: In function `testing::internal::ExpectationBase::call_count() const':                                                                                      
my_test.cpp:(.text._ZNK7testing8internal15ExpectationBase10call_countEv[testing::internal::ExpectationBase::call_count() const]+0xd): undefined reference to `testing::internal::g_gmock_mutex'                                                                                                                                             
my_test.o: In function `testing::internal::ExpectationBase::IncrementCallCount()':                                                                                    
my_test.cpp:(.text._ZN7testing8internal15ExpectationBase18IncrementCallCountEv[testing::internal::ExpectationBase::IncrementCallCount()]+0xd): undefined reference to `testing::internal::g_gmock_mutex'                                                                                                                                    
my_test.o: In function `MockFoo::Get()':                                                                                                                              
my_test.cpp:(.text._ZN7MockFoo3GetEv[MockFoo::Get()]+0x24): undefined reference to `testing::internal::UntypedFunctionMockerBase::SetOwnerAndName(void const*, char const*)'                                                                                                                                                                
my_test.o: In function `MockFoo::gmock_Get()':                                                                                                                        
my_test.cpp:(.text._ZN7MockFoo9gmock_GetEv[MockFoo::gmock_Get()]+0x1f): undefined reference to `testing::internal::UntypedFunctionMockerBase::RegisterOwner(void const*)'                                                                                                                                                                   
my_test.o: In function `testing::internal::FunctionMockerBase<int ()()>::FunctionMockerBase()':                                                                       
my_test.cpp:(.text._ZN7testing8internal18FunctionMockerBaseIFivEEC2Ev[_ZN7testing8internal18FunctionMockerBaseIFivEEC5Ev]+0x14): undefined reference to `testing::internal::UntypedFunctionMockerBase::UntypedFunctionMockerBase()'                                                                                                         
my_test.o: In function `testing::internal::FunctionMockerBase<int ()()>::~FunctionMockerBase()':                                                                      
my_test.cpp:(.text._ZN7testing8internal18FunctionMockerBaseIFivEED2Ev[_ZN7testing8internal18FunctionMockerBaseIFivEED5Ev]+0x1f): undefined reference to `testing::internal::g_gmock_mutex'                                                                                                                                                  
my_test.cpp:(.text._ZN7testing8internal18FunctionMockerBaseIFivEED2Ev[_ZN7testing8internal18FunctionMockerBaseIFivEED5Ev]+0x33): undefined reference to `testing::internal::UntypedFunctionMockerBase::VerifyAndClearExpectationsLocked()'                                                                                                  
my_test.cpp:(.text._ZN7testing8internal18FunctionMockerBaseIFivEED2Ev[_ZN7testing8internal18FunctionMockerBaseIFivEED5Ev]+0x3f): undefined reference to `testing::Mock::UnregisterLocked(testing::internal::UntypedFunctionMockerBase*)'                                                                                                    
my_test.cpp:(.text._ZN7testing8internal18FunctionMockerBaseIFivEED2Ev[_ZN7testing8internal18FunctionMockerBaseIFivEED5Ev]+0x85): undefined reference to `testing::internal::UntypedFunctionMockerBase::~UntypedFunctionMockerBase()'                                                                                                        
my_test.cpp:(.text._ZN7testing8internal18FunctionMockerBaseIFivEED2Ev[_ZN7testing8internal18FunctionMockerBaseIFivEED5Ev]+0x9f): undefined reference to `testing::internal::UntypedFunctionMockerBase::~UntypedFunctionMockerBase()'                                                                                                        
my_test.o: In function `testing::internal::MockSpec<int ()()>::InternalExpectedAt(char const*, int, char const*, char const*)':                                       
my_test.cpp:(.text._ZN7testing8internal8MockSpecIFivEE18InternalExpectedAtEPKciS5_S5_[testing::internal::MockSpec<int ()()>::InternalExpectedAt(char const*, int, char const*, char const*)]+0x20b): undefined reference to `testing::internal::LogWithLocation(testing::internal::LogSeverity, char const*, int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'                                                                                                                 
my_test.o: In function `testing::internal::TypedExpectation<int ()()>::Times(int)':                                                                                   
my_test.cpp:(.text._ZN7testing8internal16TypedExpectationIFivEE5TimesEi[testing::internal::TypedExpectation<int ()()>::Times(int)]+0x1f): undefined reference to `testing::Exactly(int)'                                                                                                                                                    
my_test.o: In function `testing::internal::TypedExpectation<int ()()>::WillOnce(testing::Action<int ()()> const&)':                                                   
my_test.cpp:(.text._ZN7testing8internal16TypedExpectationIFivEE8WillOnceERKNS_6ActionIS2_EE[testing::internal::TypedExpectation<int ()()>::WillOnce(testing::Action<int ()()> const&)]+0x144): undefined reference to `testing::Exactly(int)'                                                                                               
my_test.o: In function `testing::internal::FunctionMockerBase<int ()()>::InvokeWith(std::tr1::tuple<> const&)':                                                       
my_test.cpp:(.text._ZN7testing8internal18FunctionMockerBaseIFivEE10InvokeWithERKNSt3tr15tupleIIEEE[testing::internal::FunctionMockerBase<int ()()>::InvokeWith(std::tr1::tuple<> const&)]+0x1f): undefined reference to `testing::internal::UntypedFunctionMockerBase::UntypedInvokeWith(void const*)'                                      
my_test.o: In function `testing::internal::FunctionMockerBase<int ()()>::ClearDefaultActionsLocked()':                                                                
my_test.cpp:(.text._ZN7testing8internal18FunctionMockerBaseIFivEE25ClearDefaultActionsLockedEv[testing::internal::FunctionMockerBase<int ()()>::ClearDefaultActionsLocked()]+0xe): undefined reference to `testing::internal::g_gmock_mutex'                                                                                                
my_test.o: In function `testing::internal::FunctionMockerBase<int ()()>::AddNewExpectation(char const*, int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::tr1::tuple<> const&)':                                                                                                                     
my_test.cpp:(.text._ZN7testing8internal18FunctionMockerBaseIFivEE17AddNewExpectationEPKciRKSsRKNSt3tr15tupleIIEEE[testing::internal::FunctionMockerBase<int ()()>::AddNewExpectation(char const*, int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::tr1::tuple<> const&)]+0x28): undefined reference to `testing::internal::UntypedFunctionMockerBase::MockObject() const'                                                                                                 
my_test.cpp:(.text._ZN7testing8internal18FunctionMockerBaseIFivEE17AddNewExpectationEPKciRKSsRKNSt3tr15tupleIIEEE[testing::internal::FunctionMockerBase<int ()()>::AddNewExpectation(char const*, int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::tr1::tuple<> const&)]+0x3a): undefined reference to `testing::Mock::RegisterUseByOnCallOrExpectCall(void const*, char const*, int)'                                                                                    
my_test.cpp:(.text._ZN7testing8internal18FunctionMockerBaseIFivEE17AddNewExpectationEPKciRKSsRKNSt3tr15tupleIIEEE[testing::internal::FunctionMockerBase<int ()()>::AddNewExpectation(char const*, int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::tr1::tuple<> const&)]+0xbc): undefined reference to `testing::internal::g_gmock_implicit_sequence'                                                                                                                     
my_test.cpp:(.text._ZN7testing8internal18FunctionMockerBaseIFivEE17AddNewExpectationEPKciRKSsRKNSt3tr15tupleIIEEE[testing::internal::FunctionMockerBase<int ()()>::AddNewExpectation(char const*, int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::tr1::tuple<> const&)]+0xe2): undefined reference to `testing::Expectation::Expectation(testing::internal::linked_ptr<testing::internal::ExpectationBase> const&)'                                                      
my_test.cpp:(.text._ZN7testing8internal18FunctionMockerBaseIFivEE17AddNewExpectationEPKciRKSsRKNSt3tr15tupleIIEEE[testing::internal::FunctionMockerBase<int ()()>::AddNewExpectation(char const*, int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::tr1::tuple<> const&)]+0xf5): undefined reference to `testing::Sequence::AddExpectation(testing::Expectation const&) const'                                                                                             
my_test.cpp:(.text._ZN7testing8internal18FunctionMockerBaseIFivEE17AddNewExpectationEPKciRKSsRKNSt3tr15tupleIIEEE[testing::internal::FunctionMockerBase<int ()()>::AddNewExpectation(char const*, int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::tr1::tuple<> const&)]+0x108): undefined reference to `testing::Expectation::~Expectation()'                                                                                                                            
my_test.cpp:(.text._ZN7testing8internal18FunctionMockerBaseIFivEE17AddNewExpectationEPKciRKSsRKNSt3tr15tupleIIEEE[testing::internal::FunctionMockerBase<int ()()>::AddNewExpectation(char const*, int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::tr1::tuple<> const&)]+0x11c): undefined reference to `testing::Expectation::~Expectation()'                                                                                                                            
my_test.o: In function `testing::internal::TypedExpectation<int ()()>::Times(testing::Cardinality const&)':                                                           
my_test.cpp:(.text._ZN7testing8internal16TypedExpectationIFivEE5TimesERKNS_11CardinalityE[testing::internal::TypedExpectation<int ()()>::Times(testing::Cardinality const&)]+0x1f): undefined reference to `testing::internal::ExpectationBase::UntypedTimes(testing::Cardinality const&)'                                                  
my_test.o: In function `testing::internal::TypedExpectation<int ()()>::TypedExpectation(testing::internal::FunctionMockerBase<int ()()>*, char const*, int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::tr1::tuple<> const&)':                                                                      
my_test.cpp:(.text._ZN7testing8internal16TypedExpectationIFivEEC2EPNS0_18FunctionMockerBaseIS2_EEPKciRKSsRKNSt3tr15tupleIIEEE[_ZN7testing8internal16TypedExpectationIFivEEC5EPNS0_18FunctionMockerBaseIS2_EEPKciRKSsRKNSt3tr15tupleIIEEE]+0x38): undefined reference to `testing::internal::ExpectationBase::ExpectationBase(char const*, int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'                                                                                    
my_test.cpp:(.text._ZN7testing8internal16TypedExpectationIFivEEC2EPNS0_18FunctionMockerBaseIS2_EEPKciRKSsRKNSt3tr15tupleIIEEE[_ZN7testing8internal16TypedExpectationIFivEEC5EPNS0_18FunctionMockerBaseIS2_EEPKciRKSsRKNSt3tr15tupleIIEEE]+0xb8): undefined reference to `testing::internal::ExpectationBase::~ExpectationBase()'            
my_test.o: In function `__gnu_cxx::new_allocator<testing::Expectation>::destroy(testing::Expectation*)':                                                              
my_test.cpp:(.text._ZN9__gnu_cxx13new_allocatorIN7testing11ExpectationEE7destroyEPS2_[__gnu_cxx::new_allocator<testing::Expectation>::destroy(testing::Expectation*)]+0x18): undefined reference to `testing::Expectation::~Expectation()'                                                                                                  
my_test.o:(.rodata._ZTIN7testing8internal16TypedExpectationIFivEEE[typeinfo for testing::internal::TypedExpectation<int ()()>]+0x10): undefined reference to `typeinfo for testing::internal::ExpectationBase'                                                                                                                              
my_test.o:(.rodata._ZTIN7testing8internal18FunctionMockerBaseIFivEEE[typeinfo for testing::internal::FunctionMockerBase<int ()()>]+0x10): undefined reference to `typeinfo for testing::internal::UntypedFunctionMockerBase'                                                                                                                
my_test.o: In function `testing::internal::TypedExpectation<int ()()>::~TypedExpectation()':                                                                          
my_test.cpp:(.text._ZN7testing8internal16TypedExpectationIFivEED2Ev[_ZN7testing8internal16TypedExpectationIFivEED5Ev]+0x22): undefined reference to `testing::internal::ExpectationBase::CheckActionCountIfNotDone() const'                                                                                                                 
my_test.cpp:(.text._ZN7testing8internal16TypedExpectationIFivEED2Ev[_ZN7testing8internal16TypedExpectationIFivEED5Ev]+0x122): undefined reference to `testing::internal::ExpectationBase::~ExpectationBase()'                                                                                                                               
my_test.cpp:(.text._ZN7testing8internal16TypedExpectationIFivEED2Ev[_ZN7testing8internal16TypedExpectationIFivEED5Ev]+0x13c): undefined reference to `testing::internal::ExpectationBase::~ExpectationBase()'                                                                                                                               
my_test.o: In function `testing::internal::TypedExpectation<int ()()>::GetHandle()':                                                                                  
my_test.cpp:(.text._ZN7testing8internal16TypedExpectationIFivEE9GetHandleEv[testing::internal::TypedExpectation<int ()()>::GetHandle()]+0x29): undefined reference to `testing::internal::UntypedFunctionMockerBase::GetHandleOf(testing::internal::ExpectationBase*)'                                                                      
my_test.o: In function `testing::internal::FunctionMockerBase<int ()()>::UntypedDescribeUninterestingCall(void const*, std::basic_ostream<char, std::char_traits<char> >*) const':                                                                                                                                                          
my_test.cpp:(.text._ZNK7testing8internal18FunctionMockerBaseIFivEE32UntypedDescribeUninterestingCallEPKvPSo[testing::internal::FunctionMockerBase<int ()()>::UntypedDescribeUninterestingCall(void const*, std::basic_ostream<char, std::char_traits<char> >*) const]+0x4d): undefined reference to `testing::internal::UntypedFunctionMockerBase::Name() const'                                                                                                                                                  
my_test.o: In function `testing::internal::FunctionMockerBase<int ()()>::UntypedFindMatchingExpectation(void const*, void const**, bool*, std::basic_ostream<char, std::char_traits<char> >*, std::basic_ostream<char, std::char_traits<char> >*)':                                                                                         
my_test.cpp:(.text._ZN7testing8internal18FunctionMockerBaseIFivEE30UntypedFindMatchingExpectationEPKvPS5_PbPSoS8_[testing::internal::FunctionMockerBase<int ()()>::UntypedFindMatchingExpectation(void const*, void const**, bool*, std::basic_ostream<char, std::char_traits<char> >*, std::basic_ostream<char, std::char_traits<char> >*)]+0x30): undefined reference to `testing::internal::g_gmock_mutex'                                                                                                     
my_test.o: In function `testing::internal::FunctionMockerBase<int ()()>::FindMatchingExpectationLocked(std::tr1::tuple<> const&) const':                              
my_test.cpp:(.text._ZNK7testing8internal18FunctionMockerBaseIFivEE29FindMatchingExpectationLockedERKNSt3tr15tupleIIEEE[testing::internal::FunctionMockerBase<int ()()>::FindMatchingExpectationLocked(std::tr1::tuple<> const&) const]+0x11): undefined reference to `testing::internal::g_gmock_mutex'                                     
my_test.o: In function `testing::internal::FunctionMockerBase<int ()()>::FormatUnexpectedCallMessageLocked(std::tr1::tuple<> const&, std::basic_ostream<char, std::char_traits<char> >*, std::basic_ostream<char, std::char_traits<char> >*) const':                                                                                        
my_test.cpp:(.text._ZNK7testing8internal18FunctionMockerBaseIFivEE33FormatUnexpectedCallMessageLockedERKNSt3tr15tupleIIEEEPSoS9_[testing::internal::FunctionMockerBase<int ()()>::FormatUnexpectedCallMessageLocked(std::tr1::tuple<> const&, std::basic_ostream<char, std::char_traits<char> >*, std::basic_ostream<char, std::char_traits<char> >*) const]+0x19): undefined reference to `testing::internal::g_gmock_mutex'                                                                                     
my_test.o: In function `testing::internal::TypedExpectation<int ()()>::GetActionForArguments(testing::internal::FunctionMockerBase<int ()()> const*, std::tr1::tuple<> const&, std::basic_ostream<char, std::char_traits<char> >*, std::basic_ostream<char, std::char_traits<char> >*)':
my_test.cpp:(.text._ZN7testing8internal16TypedExpectationIFivEE21GetActionForArgumentsEPKNS0_18FunctionMockerBaseIS2_EERKNSt3tr15tupleIIEEEPSoSD_[testing::internal::TypedExpectation<int ()()>::GetActionForArguments(testing::internal::FunctionMockerBase<int ()()> const*, std::tr1::tuple<> const&, std::basic_ostream<char, std::char_traits<char> >*, std::basic_ostream<char, std::char_traits<char> >*)]+0x1e): undefined reference to `testing::internal::g_gmock_mutex'
my_test.cpp:(.text._ZN7testing8internal16TypedExpectationIFivEE21GetActionForArgumentsEPKNS0_18FunctionMockerBaseIS2_EERKNSt3tr15tupleIIEEEPSoSD_[testing::internal::TypedExpectation<int ()()>::GetActionForArguments(testing::internal::FunctionMockerBase<int ()()> const*, std::tr1::tuple<> const&, std::basic_ostream<char, std::char_traits<char> >*, std::basic_ostream<char, std::char_traits<char> >*)]+0x7a): undefined reference to `testing::internal::ExpectationBase::DescribeCallCountTo(std::basic_ostream<char, std::char_traits<char> >*) const'
my_test.cpp:(.text._ZN7testing8internal16TypedExpectationIFivEE21GetActionForArgumentsEPKNS0_18FunctionMockerBaseIS2_EERKNSt3tr15tupleIIEEEPSoSD_[testing::internal::TypedExpectation<int ()()>::GetActionForArguments(testing::internal::FunctionMockerBase<int ()()> const*, std::tr1::tuple<> const&, std::basic_ostream<char, std::char_traits<char> >*, std::basic_ostream<char, std::char_traits<char> >*)]+0x9c): undefined reference to `testing::internal::ExpectationBase::RetireAllPreRequisites()'
my_test.o: In function `testing::internal::TypedExpectation<int ()()>::ShouldHandleArguments(std::tr1::tuple<> const&) const':
my_test.cpp:(.text._ZNK7testing8internal16TypedExpectationIFivEE21ShouldHandleArgumentsERKNSt3tr15tupleIIEEE[testing::internal::TypedExpectation<int ()()>::ShouldHandleArguments(std::tr1::tuple<> const&) const]+0x11): undefined reference to `testing::internal::g_gmock_mutex'
my_test.cpp:(.text._ZNK7testing8internal16TypedExpectationIFivEE21ShouldHandleArgumentsERKNSt3tr15tupleIIEEE[testing::internal::TypedExpectation<int ()()>::ShouldHandleArguments(std::tr1::tuple<> const&) const]+0x22): undefined reference to `testing::internal::ExpectationBase::CheckActionCountIfNotDone() const'
my_test.cpp:(.text._ZNK7testing8internal16TypedExpectationIFivEE21ShouldHandleArgumentsERKNSt3tr15tupleIIEEE[testing::internal::TypedExpectation<int ()()>::ShouldHandleArguments(std::tr1::tuple<> const&) const]+0x41): undefined reference to `testing::internal::ExpectationBase::AllPrerequisitesAreSatisfied() const'
my_test.o: In function `testing::internal::FunctionMockerBase<int ()()>::PrintTriedExpectationsLocked(std::tr1::tuple<> const&, std::basic_ostream<char, std::char_traits<char> >*) const':
my_test.cpp:(.text._ZNK7testing8internal18FunctionMockerBaseIFivEE28PrintTriedExpectationsLockedERKNSt3tr15tupleIIEEEPSo[testing::internal::FunctionMockerBase<int ()()>::PrintTriedExpectationsLocked(std::tr1::tuple<> const&, std::basic_ostream<char, std::char_traits<char> >*) const]+0x16): undefined reference to `testing::internal::g_gmock_mutex'
my_test.cpp:(.text._ZNK7testing8internal18FunctionMockerBaseIFivEE28PrintTriedExpectationsLockedERKNSt3tr15tupleIIEEEPSo[testing::internal::FunctionMockerBase<int ()()>::PrintTriedExpectationsLocked(std::tr1::tuple<> const&, std::basic_ostream<char, std::char_traits<char> >*) const]+0x15d): undefined reference to `testing::internal::ExpectationBase::DescribeCallCountTo(std::basic_ostream<char, std::char_traits<char> >*) const'
my_test.o: In function `testing::internal::TypedExpectation<int ()()>::GetCurrentAction(testing::internal::FunctionMockerBase<int ()()> const*, std::tr1::tuple<> const&) const':
my_test.cpp:(.text._ZNK7testing8internal16TypedExpectationIFivEE16GetCurrentActionEPKNS0_18FunctionMockerBaseIS2_EERKNSt3tr15tupleIIEEE[testing::internal::TypedExpectation<int ()()>::GetCurrentAction(testing::internal::FunctionMockerBase<int ()()> const*, std::tr1::tuple<> const&) const]+0x24): undefined reference to `testing::internal::g_gmock_mutex'
my_test.cpp:(.text._ZNK7testing8internal16TypedExpectationIFivEE16GetCurrentActionEPKNS0_18FunctionMockerBaseIS2_EERKNSt3tr15tupleIIEEE[testing::internal::TypedExpectation<int ()()>::GetCurrentAction(testing::internal::FunctionMockerBase<int ()()> const*, std::tr1::tuple<> const&) const]+0x253): undefined reference to `testing::internal::Log(testing::internal::LogSeverity, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
my_test.o: In function `testing::internal::TypedExpectation<int ()()>::Matches(std::tr1::tuple<> const&) const':
my_test.cpp:(.text._ZNK7testing8internal16TypedExpectationIFivEE7MatchesERKNSt3tr15tupleIIEEE[testing::internal::TypedExpectation<int ()()>::Matches(std::tr1::tuple<> const&) const]+0x11): undefined reference to `testing::internal::g_gmock_mutex'
my_test.o: In function `testing::internal::TypedExpectation<int ()()>::ExplainMatchResultTo(std::tr1::tuple<> const&, std::basic_ostream<char, std::char_traits<char> >*) const':
my_test.cpp:(.text._ZNK7testing8internal16TypedExpectationIFivEE20ExplainMatchResultToERKNSt3tr15tupleIIEEEPSo[testing::internal::TypedExpectation<int ()()>::ExplainMatchResultTo(std::tr1::tuple<> const&, std::basic_ostream<char, std::char_traits<char> >*) const]+0x24): undefined reference to `testing::internal::g_gmock_mutex'
my_test.cpp:(.text._ZNK7testing8internal16TypedExpectationIFivEE20ExplainMatchResultToERKNSt3tr15tupleIIEEEPSo[testing::internal::TypedExpectation<int ()()>::ExplainMatchResultTo(std::tr1::tuple<> const&, std::basic_ostream<char, std::char_traits<char> >*) const]+0x20b): undefined reference to `testing::internal::ExpectationBase::AllPrerequisitesAreSatisfied() const'
my_test.cpp:(.text._ZNK7testing8internal16TypedExpectationIFivEE20ExplainMatchResultToERKNSt3tr15tupleIIEEEPSo[testing::internal::TypedExpectation<int ()()>::ExplainMatchResultTo(std::tr1::tuple<> const&, std::basic_ostream<char, std::char_traits<char> >*) const]+0x26c): undefined reference to `testing::internal::ExpectationBase::FindUnsatisfiedPrerequisites(testing::ExpectationSet*) const'
collect2: ld returned 1 exit status

Billy Donahue

unread,
Jul 30, 2013, 12:31:40 PM7/30/13
to Roey Chen, googl...@googlegroups.com
# g++  -lpthread -lgtest my_test.o -o my_test

1) Are you compiling C++ code as root? :)
2) Try changing the order of your command line args.

       g++ 
my_test.o  -lpthread -lgtest -o my_test


--
 
---
You received this message because you are subscribed to the Google Groups "Google C++ Mocking Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to googlemock+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/googlemock/515de815-8120-42af-ad65-265444118834%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
 
---
You received this message because you are subscribed to the Google Groups "gMock-users" group.
To view this discussion on the web visit https://groups.google.com/a/google.com/d/msgid/gmock-users/515de815-8120-42af-ad65-265444118834%40googlegroups.com.
 
 

Roey Chen

unread,
Jul 31, 2013, 7:59:56 AM7/31/13
to Billy Donahue, googl...@googlegroups.com
Thanks for answering.

1) As a matter of fact I do, is that a bad habit?

2) I found what i did wrong, should have add '-lgmock' to the command line,
    It isn't mentioned in the README file or the project wiki page.

--
Roey

Billy Donahue

unread,
Jul 31, 2013, 9:43:51 AM7/31/13
to Roey Chen, googl...@googlegroups.com
On Wed, Jul 31, 2013 at 7:59 AM, Roey Chen <chen...@gmail.com> wrote:
Thanks for answering.

1) As a matter of fact I do, is that a bad habit?

Yes. Unless you need to be root, don't be.
You could accidentally overwrite critical system files.
 
2) I found what i did wrong, should have add '-lgmock' to the command line,
    It isn't mentioned in the README file or the project wiki page.


 
On Tue, Jul 30, 2013 at 7:31 PM, Billy Donahue <billyd...@google.com> wrote:
Reply all
Reply to author
Forward
0 new messages