google gmock 使用笔记, 编译问题

几个有用的链接: 

1, 入门介绍的:http://code.google.com/p/googlemock/wiki/ForDummies

2, cookbook: http://code.google.com/p/googlemock/wiki/CookBook 

3, http://www.codelast.com/?p=237 , 一个不错的使用小节

 

笔记: From: http://code.google.com/p/googlemock/wiki/ForDummie 

1,  So, the rule of thumb is: if you need to mock Foo and it's owned by others, define the mock class in Foo's package (better, in a testing sub-package such that you can clearly separate production code and testing utilities), and put it in a mock_foo.h. Then everyone can referencemock_foo.h from their tests. If Foo ever changes, there is only one copy of MockFoo to change, and only tests that depend on the changed methods need to be fixed.

 

编译问题: 

1.6的版本,  似乎是Makefile写的不完善. 不能直接./configure; make;  make install ,

make 之后也只能在生成*.la 的文件.

解决办法:

configure 后进入make 目录.

执行makefile, 但还是只能编译出 gmock_main.a 来. 

查看makefile 文件: 

gmock.a : gmock-all.o gtest-all.o
$(AR) $(ARFLAGS) $@ $^

gmock_main.a : gmock-all.o gtest-all.o gmock_main.o
$(AR) $(ARFLAGS) $@ $^

似乎是gmock.a 并没有编译. 但是可以发现 gmock.a 和gmock_main.a 是差不多的~~~

于是我直接把gmock.a 拷贝到gmock安装目录下, 重命名为: libgmock.a 

再次编译我的demo程序. 

可行!

posted on 2011-10-28 16:21  foreveryl  阅读(913)  评论(0)    收藏  举报