如何在 VC++ 中自动链接调试/发布库 6.0?
我正在尝试维护 5 年前用 VC++ 6.0 编写的程序。 它使用我们的“通用”库。 我遇到的问题是,它要么链接到这些库的调试版本,要么链接到发布版本,具体取决于我是否将[库文件]的[目录]设置为[中的“common/debug”或“common/release”工具]->[选项]。
如何让它在构建调试版本时链接到 [common\debug\common.lib] 和构建发布版本时链接到 [common\release\common.lib]? 如果我在库目录中有两个路径,它似乎链接到它找到的第一个路径。
I am trying to maintain a program written 5 years ago in VC++ 6.0. It uses our 'common' libraries. The trouble I have is that it either links against the debug version of these libraries or the Release version, depending on whether I have the [Directories] for [library files] set to "common/debug" or "common/release" in [Tools]->[Options].
How do I get it to link to [common\debug\common.lib] when building the debug version and [common\release\common.lib] when building the release version? If I have both paths in the library directories, it seems to link to the first one it finds.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
无需在包含文件夹中指定路径,我根据配置使用包含库的所有最佳方法是使用 #pragma
尝试一次,它非常有用
Instead of specifying the paths in the include folders and all the best way i use to include the libraries depending on the configuration is by using #pragma
try this once, it is very useful
在[项目属性]->[链接器]->[输入]->[附加依赖项]中,您可以使用 $(ConfigurationName) 占位符,如下所示:
在调试配置中,这将更改为:
在发布中将更改为:
In [Project Properties]->[Linker]->[Input]->[Additional Dependencies] you can use the $(ConfigurationName) placeholder, like this:
In the Debug configuration this will change to:
and in Release it will change to:
只需添加用于调试设置的 debug 文件夹和用于发布设置的发布文件夹。
几乎所有编译器、链接等设置都是按配置进行的(如果调试和发布不同,项目属性将在“所有配置”中将设置显示为空白(如果我记得正确的文本))。
Just add the debug folder for the debug settings and the release folder for release settings.
Almost all compiler, linking etc. settings are per configuration (the project properties will show settings as blank in "all configurations" (if I recall the right text) if debug and release are different.
您可以在“附加依赖项”字段中指定要链接到的库的完整路径,这对于调试和发布版本可以具有不同的值。
You could specify the full path of the library to link to in the Additional Dependancies field, this can have different values for debug and release builds.
我找到的解决方案有点像理查德的& “1800信息”的...
我从
工具->选项
中删除了公共库路径。 这里的路径对于在 MSVS VC++ 6.0 中运行的所有项目的所有配置都是全局的。然后,我在每个配置的
Project->Settings
中添加了相应库的完整路径。 因此,调试配置具有D:\VSS\Common\Debug\Common.lib
,发布配置具有D:\VSS\Common\Release\Common.lib
。 这似乎有效,并且我第一次没有构建警告!感谢所有为我指明正确方向的建议。
——阿利斯泰尔。
The solution I have found is a little like Richard's & "1800 Information"'s...
I removed the Common library path from
Tools->Options
. The paths in here are global to all configurations of all projects running in MSVS VC++ 6.0.I then added a full path to the appropriate library in
Project->Settings
for each configuration. Hense the debug configuration hasD:\VSS\Common\Debug\Common.lib
and the release configuration hasD:\VSS\Common\Release\Common.lib
. This seems to work and for the first time I have no build warnings!Thanks to all the suggestions for pointing me in what seems to be the right direction.
--- Alistair.