每个项目配置如何具有不同的项目依赖关系?

编程入门 行业动态 更新时间:2024-10-28 18:23:03
本文介绍了每个项目配置如何具有不同的项目依赖关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

根据当前正在构建的项目配置,我希望具有不同的项目依赖关系.

例如,我不想在Release配置中构建和链接SomeTestLib.vcproj,但是我想在Debug中构建并链接到它.

一种有效的解决方案是使用条件编译宏:

#ifdef DEBUG #pragma comment( lib, "SomeTestLib" ) #endif

但是在这种情况下,调试器和IntelliSense不适用于SomeTestLib. 我可以使用.sln或.vcproj黑客吗? 谢谢.

解决方案

在Google搜索了几天之后,我终于放弃了寻找此问题的解决方案,并让VS开发人员大吃一惊,后者为我提供了解决该问题的方法(实际上,我自己尝试了数十亿种不同的方法来找到它).

显然,IDE不够智能,无法确定您已在给定配置下禁用了为特定库的构建,并且没有将该项目的输出添加到依赖于该库的项目的链接器命令行中.我确定您知道这一点.

但是,由于它只是将库项目的输出行粘贴到从属项目的命令行中,因此将输出行设置为"将导致NOTHING被添加到从属项目的链接器命令行中! >

希望此问题将来在Visual Studio中得以解决.我仍然很乐观,因为它是我最喜欢的IDE,并且它所支持的功能总是给我留下深刻的印象.但是,我见过的某些VS帮助线程说此错误是设计使然"的,因此也许他们无法修复它.不过,这似乎很容易做到.

无论如何,总结一下:

  • 在解决方案资源管理器中右键单击您的库项目,然后单击属性".
  • 切换到您的库项目未为其构建的配置/平台"对.
  • 选择配置属性->图书馆员->常规".
  • 对于输出文件",键入"(即打开的空格,空格,关闭的空格).
  • 单击确定".

请注意,如果您生成或清理禁用的库项目,此解决方法将给您错误.如果您只是构建解决方案,则在禁用的配置上将跳过该解决方案,因此不会出现错误.

希望这会有所帮助!

丹尼尔

I would like to have different Project Dependencies depending on which Project Configuration I'm currently building.

For example, I don't want to build and link SomeTestLib.vcproj in Release configuration, but I'd like to build and link to it in Debug.

One solution, that sorta works, is to use conditional compilation macros:

#ifdef DEBUG #pragma comment( lib, "SomeTestLib" ) #endif

But in this case, the debugger and IntelliSense don't work for SomeTestLib. Is there a .sln or .vcproj hack that I could use? Thanks.

解决方案

After searching Google for days, I finally gave up on finding a solution to this problem and blew a VS developer, who gave me the workaround for this problem (actually, I tried a bajillion different things on my own to find this).

Apparently, the IDE isn't smart enough to figure out that you've disabled building for a particular library under a given configuration and to not add that project's output to the linker command line for projects that depend on it. I'm sure that you are aware of this.

However, since it is just pasting the output line from the library project into the command line of the dependent project, setting the output line to " " will result in NOTHING being added to the linker command line on dependent projects!

Hopefully, this problem will be remedied in Visual Studio in the future. I remain optimistic, because it is my favorite IDE, and I am always impressed by the features it supports. However, some of the VS help threads that I've seen say that this bug is "by design", so maybe they won't fix it. It seems easy enough to do, though.

Anyways, to summarize:

  • Right-Click on your library project in the Solution Explorer and Click "Properties".
  • Switch to the "Configuration/Platform" pair that your library project does not build for.
  • Select "Configuration Properties -> Librarian -> General".
  • For "Output File", type " " (that is open parens, space, close parens).
  • Click OK.

Please note that this workaround will give you errors if you Build or Clean the disabled library project. If you just build your solution, it will be skipped on disabled configurations, so you won't get errors.

Hope this helps!

Daniel

更多推荐

每个项目配置如何具有不同的项目依赖关系?

本文发布于:2023-11-22 09:04:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1616803.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:项目   关系

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!