如何在 Visual Studio 2010 的同一解决方案中使用另一个项目中的类?

发布于 2024-10-03 18:45:54 字数 410 浏览 1 评论 0原文

我正在开发一个用 C++ 编写的面向对象的 Windows API 包装器库,并且解决方案中有两个项目:

  • 实际的库项目;
  • 一个“测试”项目,我在其中编写使用该库进行测试的代码。

我的目标是能够在测试项目中包含和使用库头文件,就像它是使用该库的实际项目一样。

我通过将“$(SolutionDir)”添加到测试项目的附加包含目录来解决文件包含问题(有更干净的方法吗?),但我正在努力让测试项目链接。我收到未引用的外部错误,我认为这是因为链接器找不到 DLL。

我完全迷失在这里了。我已经设置了项目到项目的引用,以便测试项目依赖于库项目,但这并没有解决链接问题。我在这两个项目的属性中都找不到任何与我的问题相关的选项。

有没有一种方法可以简单地点击“构建解决方案”,然后运行可执行文件?

I'm working on a object-oriented Windows API wrapper library, written in C++, and I have two projects inside the solution:

  • The actual library project;
  • A "test" project, where I write code that uses the library for testing purposes.

My goal is to be able to include and use the library header files on the test project, as if it was an actual project that uses the library.

I solved the file inclusion problem by adding "$(SolutionDir)" to the test project's additional include directories (is there a cleaner way?), but I'm struggling to get the test project to link. I get unreferenced externals errors, which I assume is because the linker can't find the DLL.

I'm completely lost here. I have set up project-to-project references, so that the test project is dependent on the library project, but that did not solve the linking problem. I couldn't find any option in either project's properties that seemed to be relevant to my problem.

Is there a way I can simply hit "Build Solution" and then run the executable?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

随波逐流 2024-10-10 18:45:54

在您的项目属性中>链接器>输入,您可以为链接器指定一堆设置,例如要链接的附加依赖项(将其他项目生成的 .lib 放在那里)以及查找所述库的路径。

In your project's properties > Linker > Input, there's a bunch of settings you can specify for the linker, such as, for instance, additionnal dependencies to link with (put the .lib generated by your other project there) and which paths to look for said libraries.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文