【发布时间】:2012-10-03 17:55:29
【问题描述】:
我使用 GoogleTest 测试我的 C++ 项目,在发现 Ubuntu 包中不再分发预编译库后,我在项目网站上发现以下内容:
如果您使用不同的编译器编译 Google Test 和您的测试代码 标志,他们可能会看到相同的不同定义 类/函数/变量(例如,由于在 Google 测试中使用了#if)。 因此,为了您的理智,我们建议您避免安装 预编译的谷歌测试库。相反,每个项目都应该 编译谷歌测试本身,这样它就可以确定相同的 标志用于 Google 测试和测试。
我从中得到的是,将 GoogleTest 与正在测试的项目分开编译是个坏主意。我不明白这是否只是 GoogleTest 的事情,或者这是否是链接库的一般事情。
问题
是否存在链接到预编译的第三方库、编译器标志或其他不安全的情况,如果没有,GoogleTest 有什么特别之处?
【问题讨论】:
-
您的报价似乎缺少重要部分:
If you compile Google Test and your test code using different compiler flags, they may see different definitions of the same class/function/variable (e.g. due to the use of #if in Google Test). -
我已经用你指出的那一点更新了报价。
标签: c++ static-libraries googletest