Howto install google-mock on Ubuntu 12.10

Posted by user1459339 on Ask Ubuntu See other posts from Ask Ubuntu or by user1459339
Published on 2012-11-19T22:36:33Z Indexed on 2012/11/19 23:23 UTC
Read the original article Hit count: 540

Filed under:
|
|
|

I am having hard time trying to install Google C++ Mocking Framework. I have successfully run sudo apt-get install google-mock. Then I tried to compile this sample file

#include "gmock/gmock.h"
int main(int argc, char** argv) {
  ::testing::InitGoogleMock(&argc, argv);
  return RUN_ALL_TESTS();
}

with g++ -lgmock main.cpp and these errors have shown

main.cpp:(.text+0x1e): undefined reference to `testing::InitGoogleMock(int*, char**)'
main.cpp:(.text+0x23): undefined reference to `testing::UnitTest::GetInstance()'
main.cpp:(.text+0x2b): undefined reference to `testing::UnitTest::Run()'
collect2: error: ld returned 1 exit status

I guess the linker can not find the library files. Does anybody know how to fix this?

© Ask Ubuntu or respective owner

Related posts about installation

Related posts about programming