如何在同一个解决方案的不同项目中使用相同的obj文件 [英] How to use the same obj files in different projects in the same solution

查看:47
本文介绍了如何在同一个解决方案的不同项目中使用相同的obj文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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?

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

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...

在项目 1 中

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

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

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

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

project3 同样的事情.等

project3 same thing. etc.

我也在 MS 论坛上发布了此消息,但尚未收到答复.

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

推荐答案

如果您可以重新组织代码以执行此操作,请将共享的 .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.

这篇关于如何在同一个解决方案的不同项目中使用相同的obj文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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