调试信息{$ D +}将我的EXE的大小增加了6MB [英] Debug information {$D+} increases the size of my EXE with 6MB

查看:73
本文介绍了调试信息{$ D +}将我的EXE的大小增加了6MB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Delphi文档说
调试信息不​​会影响可执行程序的大小或速度。

Delphi documentation says that "Debug information [...] it does not affect the size or speed of the executable program."

但是,当我激活调试信息时(在项目选项->链接器中),我的EXE从1.8MB变为7MB。
我在做什么错?

However, when I activate Debug information (in Project Options -> Linker) my EXE goes from 1.8MB to 7MB. What am I doing wrong?

注意:我想在链接下的调试信息与编译下的调试信息相同,因为它们具有相同的编译器指令({$ D})。

Note: I suppose that the 'Debug information' under 'Linking' is the same as 'Debug information' under 'Compiling' since they have the same compiler directive ( {$D} ).

推荐答案

您的假设不正确。使用调试信息进行编译意味着编译器会生成具有调试信息的DCU。链接调试信息意味着链接器将调试信息从DCU放入最终的二进制文件中,而不是将其剥离出来,因此当然会使二进制文件大得多。

Your assumption is incorrect. Compiling with debug information means that the compiler generates DCUs with debug information. Linking with debug information means that the linker puts the debug info from the DCUs into the final binary instead of stripping it out, so of course that will make the binary a lot bigger.

没有调试信息的链接通常是可以的,因为只要调试器可以找到DCU,就可以获取DCU中的调试信息。但是,如果您需要在无法使用DCU的情况下调试应用,则需要打开链接选项。

Linking without debug info is usually OK, since the debugger can get at the debug info in the DCUs as long as it can find them. But if you need to debug your app in some scenario where the DCUs won't be available, you'll want the link option turned on.

这篇关于调试信息{$ D +}将我的EXE的大小增加了6MB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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