gtest.lib和gtest_main.lib有什么区别? [英] What's the difference between gtest.lib and gtest_main.lib?

查看:728
本文介绍了gtest.lib和gtest_main.lib有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google的C ++测试框架具有两个输出库:一个是gtest.lib,另一个是gtest_main.lib.根据 Nik Reiman的>如何回答使用Visual Studio设置gtest ,我们应该链接到gtest_main.lib,但是我正在链接到gtest.lib和我运行的示例测试用例.

Google's C++ Test Framework has two output libraries: one is gtest.lib and the other one is gtest_main.lib. According to Nik Reiman's answer on how to setup gtest with Visual Studio, we should link to gtest_main.lib but I'm linking to gtest.lib and the sample test cases that I have are running fine.

这两个库有什么区别,我链接到哪个库有什么关系?

What's the difference between the two libraries and does it matter which one I link to?

推荐答案

唯一合理的区别是 gtest_main.lib 提供了测试应用程序入口点的默认实现(即main函数) :

the only reasonable difference is that gtest_main.lib provides a default implementation of a test application entry point (i.e. main function):

来自引用的引用从Google C ++测试框架开始:

"[[...]也许您认为写作 所有这些main()函数都太多了 工作?我们完全同意您的看法,并且 这就是为什么Google Test提供了一个 main()的基本实现.如果它 满足您的需求,然后只需链接您的 用gtest_main库测试,您 很好."

"[...] maybe you think that writing all those main() functions is too much work? We agree with you completely and that's why Google Test provides a basic implementation of main(). If it fits your needs, then just link your test with gtest_main library and you are good to go."

如果您想自己编写主要功能-您应链接 gtest.lib .

If you want to write your main function yourself - you should link with gtest.lib.

这篇关于gtest.lib和gtest_main.lib有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆