如何在同一个解决方案的不同项目中使用相同的obj文件

发布于 2024-08-28 08:32:54 字数 610 浏览 4 评论 0原文

我有一个包含多个项目的解决方案。其中一些项目共享源文件。我已经设置了项目树,以便共享源文件的项目放在一起。我的问题是,当我进行清理并构建共享源文件时,每个项目都会重新编译,而不仅仅是第一个使用它们的项目。结果是初始构建花费的时间比应有的时间长,并且我必须构建多次才能满足所有依赖项(需要重新链接)。该项目是来自 gcc 项目的端口,该项目使用一系列 make文件来执行构建。 make 文件不会重复编译。有没有什么方法可以处理上述情况,以便在 Visual Studio 中满足人们所期望的依赖关系?问题是否是由于源文件与 .idb 和 .pdb 文件之间的依赖性造成的?

更新:我真正需要的是一种方法来告诉 VS 对具有不同 DLL 和 LIB 名称的相同 obj 文件执行重新链接。我可以通过在重新链接项目中包含 .obj 文件来使其工作,但无法弄清楚如何创建调试/发布版本。在项目文件的部分中, $(IntDir) 似乎没有被解析。所以...

在项目1

file1.c file2.c file3.c 链接到dll1.dll,dll1.lib

然后在项目2 中项目1 中的目标文件再次链接到 dll2.dll,dll2.lib

项目3同样的事情。等等。

我也在微软论坛上发布了这个问题,但尚未收到答复。

I have a solution that contains several projects. Some of these projects share source files. I have set up my project tree so that the projects that share source files are together. My problem is that when I do a clean and build the shared source files get re-compiled for every project, not just the first one that uses them. The result is that the initial build takes longer than it should and I have to build more than once to get all of the dependencies satisfied (re-links are necessary.) The project is a port from a gcc project that uses a series of make files to perform the build. The make files do not repeat the compiles. Is there any way to handle the above situation so that the dependencies are satisfied in Visual Studio as one would expect? Is the problem due to a dependency between the source file and the .idb and .pdb files?

Update: What I really need is a way to tell VS to perform a re-link on the same obj files with different DLL and LIB names. I can get this to work by including .obj files in the re-link projects but haven't been able to figure out how to create debug/release versions. In the sections of the project files the $(IntDir) does not seem to get parsed. So...

In project1

file1.c file2.c file3.c link into dll1.dll,dll1.lib

then in project 2 the object files from the project1 get linked again only this time into
dll2.dll,dll2.lib

project3 same thing. etc.

I posted this on an MS forum also and as yet have not received an answer.

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

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

发布评论

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

评论(1

寄意 2024-09-04 08:33:23

如果您可以重新组织代码来执行此操作,将共享 .obj 文件构建到库项目中,然后您可以从依赖项目链接到该库。

这是我能想到的解决问题的唯一“干净”方法 - 我能想到的任何其他方法都可能涉及“战斗”或“欺骗”视觉工作室,这通常是一个坏主意。

If you can reorganise the code to do this, build the shared .obj files into a library project, then you can link with that library from the dependent projects.

That's the only "clean" way I can think of to solve the problem - anything else I can think of is likely to involve "fighting" or "tricking" visual studio, which is usually a bad idea.

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