C中Debug/和Release/目录下的lib有什么区别?

发布于 2024-09-09 06:50:21 字数 221 浏览 0 评论 0原文

当我链接到 Release/ 下的那个时,出现了致命错误:

LINK : fatal error LNK1146: no argument specified with option '/machine:'

然后我尝试链接到 Debug/ 下的 .lib ,这次它工作了。

但又有什么不同呢?

When I link to the one under Release/ ,got a fatal error:

LINK : fatal error LNK1146: no argument specified with option '/machine:'

Then I tried to link to the .lib under Debug/ and this time it works.

But what can be different?

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

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

发布评论

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

评论(3

夏雨凉 2024-09-16 06:50:21

通常,调试程序集不会进行任何优化,而发布程序集会进行优化。调试程序集通常还包含类似源文件行号的繁琐内容。

Usually, no optimization is done to debug assemblies, while release assemblies are optimized. Debug assemblies will also often contain cruft like source file line numbers.

〃温暖了心ぐ 2024-09-16 06:50:21

这实际上不是一个 C 问题;而是一个 C 问题。它与所使用的平台有关。

通常,一个项目/解决方案会创建一个用于调试的版本和一个用于发布的版本,将它们放在 Debug/ 和 Release/ 目录中是一种常见的区分方法。调试版本通常编译速度快,运行速度慢,并且包含将内部执行链接到源代码的信息(例如行号和变量名称)。发布版本通常编译速度较慢,运行速度较快,并且跟踪内部发生的情况要困难得多。

显然,调试版本和发布版本之间必须存在差异,只要有适当的编译器标志即可。然而,在我熟悉的构建系统中,可以进行任意其他更改,有时这会导致仅发布版本的错误,这是一个痛苦。或者,如果 C 代码没有正确指定行为,调试版本和发布版本可能会以不同的方式解释它,这也是一个痛苦。

在这种情况下,我猜想它们的构建方式有所不同。如果没有更多信息,我无法进一步发表评论。

操作系统是什么?使用的是什么C编译器?您使用什么构建系统(如果您使用的是 IDE,可能是 IDE 的一个标准)?你用的是什么库。它是您的组织构建的,还是从外部获取的?了解这些事情将为我们提供从哪里开始寻找的线索。

This isn't actually a C question; it relates to the platforms used.

Frequently, a project/solution will be set up to create a version for debugging and one for release, and putting them in Debug/ and Release/ directories is a common way to distinguish. The debug version will typically compile fast and run slowly, and contain information to link the internal execution to the source code (such as line numbers and variable names). The release version is typically slower to compile and faster to run, and it's much more difficult to track what's going on inside.

Obviously, there have to be differences between the debug and release versions, if only the appropriate compiler flags. However, in the build systems I'm familiar with, it's possible to make arbitrary other changes, and sometimes this will cause a release-version-only bug, which is a pain. Alternately, if the C code doesn't specify the behavior properly, the debug and release versions might interpret it differently, and that's also a pain.

In this case, I'd guess that there was a difference in how they were built. I can't really comment further without more information.

What is the OS? What is the C compiler used? What build system do you use (if you're using an IDE, possibly the one standard with the IDE)? What is the library you're using. Does your organization build it, or do you get it from outside? Knowing these things would give us a clue as to where to start looking.

尾戒 2024-09-16 06:50:21

您可能想要分别更改调试版本和发布版本的构建配置。

You may want to change the build configuration for debug and release versions seperately.

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