在我的解决方案中使用另一个项目的代码

发布于 2024-12-27 02:32:00 字数 162 浏览 1 评论 0原文

我正在尝试的方法相当常见,但我在网上找不到任何关于此的指示。 我在一个 VS 2010 解决方案中有 2 个非托管 C++ 项目。 我可以很好地编译它们,并在“解决方案”>“解决方案”下设置项目依赖项。特性。 我想做的是能够在项目 B 中使用项目 A 中的类/函数,我还需要做什么?

谢谢

what I'm trying is fairly common but I can't find any pointers about this on the web.
I have 2 unmanaged C++ projects in one VS 2010 solution.
I can compile both of them fine and I set the project dependencies right under Solution > Properties.
What I'd like to do would be to be able to use my classes / function from project A in project B, what else do I need to do?

thanks

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

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

发布评论

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

评论(1

挽清梦 2025-01-03 02:32:00

在项目属性中:

  • C/C++ 下 =>一般情况下,将包含 A 标头的文件夹添加到“其他包含目录”中。

  • 在链接器下=>一般情况下,将包含 A 输出的文件夹(要链接的 A.lib 文件)添加到“其他库目录”。

  • 在链接器下=>输入,将A.lib添加到“附加依赖项”列表中。

您需要确保项目共享相同的配置属性。例如,您不能混合针对不同运行时库构建的映像,因此您不能混合和匹配发布和调试版本。

配置完项目后,您可以将 A 的头文件包含在 B 源文件中,并从 B 中的代码调用 A 中定义的函数。

In the project properties:

  • Under C/C++ => General, add the folder containing A's headers to "Additional Include Directories."

  • Under Linker => General, add the folder containing A's output (the A.lib file that you want linked in) to "Additional Library Directories."

  • Under Linker => Input, add A.lib to the "Additional Dependencies" list.

You will need to make sure that the projects share the same configuration properties. For example, you cannot mix images built against different runtime libraries, so you can't mix and match release and debug builds.

Once you have thus configured the projects, you can include A's header file in your B source files and call the functions defined in A from your code in B.

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