Visual Studio 2017中的Google Test问题 [英] Issue with Google Test in Visual Studio 2017

查看:60
本文介绍了Visual Studio 2017中的Google Test问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Visual Studio 2017创建一个C ++项目,然后使用Google Test对其进行测试.我按照此指南创建了我的项目并为其设置了Google Test:

如果我尝试构建解决方案,则会出现以下错误:

但是,如果我没有在测试中声明Table对象,那么解决方案将成功构建.

如果您有任何想法,为什么会出现这些错误,请告诉我.谢谢!

解决方案

演练https://docs.microsoft.com/en-us/visualstudio/test/how-to-use-google-test-for-cpp

My solution has two projects Matrix and Matrix-Test (Google Test project). Project Matrix contains a class called Table. Project Matrix-Test contains a single test where a Table object is declared. Everything looks like this:

If I try to build the solution I get the following errors:

However, if I don't declare the Table object in the test, then the solution builds successfully.

Please let me know if you have any idea why I get these errors. Thank you!

解决方案

The walkthrough https://docs.microsoft.com/en-us/cpp/windows/walkthrough-creating-and-using-a-static-library-cpp?view=vs-2017 will guide you through the process of making your project Matix a static library.

Then you can add this library (e.g. Matrix.lib) as an input to the linker in the Matrix-Test project. This will solve the unresolved external symbol error in regard to your Table class.

这篇关于Visual Studio 2017中的Google Test问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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