确定哪些对象文件导致 .dll 大小增加 [C++]
我正在开发一个大型的 C++ 构建库,该库最近增长了很多。 由于其尺寸较大,导致尺寸增加的原因尚不清楚。
您是否有任何可以帮助确定增长来自何处的工具(msvc 或 gcc)建议。
编辑 我尝试过的事情:转储最终的 dll、obj 文件、创建映射文件并翻阅它。
再次编辑 所以 objdump 和 python 脚本似乎已经完成了我想要的。
I'm working on a large c++ built library that has grown by a significant amount recently. Due to it's size, it is not obvious what has caused this size increase.
Do you have any suggestions of tools (msvc or gcc) that could help determine where the growth has come from.
edit
Things i've tried: Dumpbin the final dll, the obj files, creating a map file and ripping through it.
edit again
So objdump along with a python script seems to have done what I want.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果是 gcc,则 objdump。 如果是 Visual Studio,则为 dumpbin。
我建议对旧(小)库和新(大)库的工具输出进行比较。
If gcc, objdump. If visual studio, dumpbin.
I'd suggest doing a diff of the output of the tool for the old (small) library, vs. the new (large) library.
keyersoze 的答案(比较 objdump 或 dumpbin 的输出)是正确的。 另一种方法是告诉链接器生成一个映射文件,并比较映射文件中的 DLL 的新旧版本。
link.exe
/MAP< /code>
ld
-M
(或gcc -Wl,-M
)keysersoze's answer (compare the output of
objdump
ordumpbin
) is correct. Another approach is to tell the linker to produce a map file, and compare the map files for the old and new versions of the DLL.link.exe
/MAP
ld
-M
(orgcc -Wl,-M
)在 Linux 上,应该很容易通过递归差异查看是否添加了新文件。 他们肯定会增加图书馆的规模。 然后,您可以在 Linux 上使用 size 命令行工具来获取每个新对象文件的大小并将其相加。 然后将该总和与您的图书馆增量进行比较,并检查其差异有多大。
On Linux it should be quite easy to see if new files have been added with a recursive diff. They would certainly create an increase in the library size. You can then go an use the size command line tool on Linux to get the sizes of each of the new object files and sum them up. Then compare that sum to your library increase and check how much it differs.
天哪,
如果您有任何以前版本的目标文件,您可以运行 size 命令来查看哪个段已增长吗?
有几个问题:
编辑:如果代码位于 SCM 下,您能否查看为您提供较小对象的源版本。 然后比较:
find ./tree_top ( -name *.h -o -name *.cpp ) | 的操作来计算文件数量 wc -l 通过执行 find ./tree_top ( -name *.h -o -name *.cpp ) -print | wc -l 来
HTH
顺便说一句 请在此处发布您的发现,因为我确信很多人对您的发现感兴趣。
干杯,
G'day,
If you have any previous versions of the object file laying around can you run the size command to see which segment has grown?
Couple of questions:
Edit: If the code is under SCM, can you check out a version of the source that gave you the smaller object. Then compare:
find ./tree_top ( -name *.h -o -name *.cpp ) | wc -l
find ./tree_top ( -name *.h -o -name *.cpp ) -print | sort > treelist
and then do the same for the new larger tree. Doing a simple sdiff will show any large number of new files.HTH
BTW Please post your findings here as I'm sure many people are interested in what you find out.
cheers,