我的C ++目标文件太大 [英] My C++ object file is too big

查看:184
本文介绍了我的C ++目标文件太大的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用C ++程序,一个1200行文件(用于初始化一个相当复杂的状态机)的编译后目标代码几乎达到了一个兆字节.是什么使文件如此之大?有什么方法可以找到导致目标文件占用空间的东西吗?

I am working on a C++ program and the compiled object code from a single 1200-line file (which initializes a rather complex state machine) comes out to nearly a megabyte. What could be making the file so large? Is there a way I can find what takes space inside the object file?

推荐答案

目标文件大于其最小值必须有多个原因:

There can be several reasons when object files are bigger than they have to be at minimum:

  • 静态包括依赖库
  • 使用调试信息进行构建
  • 使用分析信息进行构建
  • 使用模板(可能是递归的boost-结构)创建(极端)复杂的数据结构
  • 在编译时不打开优化标志(节省不太多,如果使用得太厉害,可能会造成困难)

起初,我建议检查您是否使用调试信息进行构建,这是我经验中最多的肿胀.

At first I suggest to check if you're building with debug information, this causes the most bloat in my experience.

这篇关于我的C ++目标文件太大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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