适用于最小可执行文件的C ++ Windows编译器 [英] C++ Windows Compiler for smallest executables

查看:219
本文介绍了适用于最小可执行文件的C ++ Windows编译器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们,我想开始用C ++编程.我已经在vb6,vb.net中编写了一些程序,现在我想获得C ++的知识,我想要的是一个可以将我的代码编译为最小的Windows应用程序的编译器.例如,有一个名为PureBasic的基本语言编译器,可以使Hello World独立应用程序的大小为5 kb,而我编译的简单套接字程序仅为12 kb(没有任何DLL-s和运行时文件).我知道这很棒,所以我想要C ++这样的东西.

guys I want to start programing with C++. I have written some programs in vb6, vb.net and now I want to gain knowledge in C++, what I want is a compiler that can compile my code to the smallest windows application. For example there is a Basic language compiler called PureBasic that can make Hello world standalone app's size 5 kb, and simple socket program which i compiled was only 12kb (without any DLL-s and Runtime files). I know it is amazing, so I want something like this for C++.

如果我错了,并且没有这种Windows编译器,有人可以给我一个网站或一本书,教我如何减小C ++可执行文件的大小,或如何使用Windows API调用吗?

If I am wrong and there is not such kind of windows compiler can someone give me a website or book that can teach me how to reduce C++ executable size, or how to use Windows API calls?

推荐答案

很多年前,我不得不使用VC6来做到这一点.这是必需的,因为可执行文件将通过有线方式传输到目标计算机,并在该计算机上运行.由于它很可能是通过调制解调器连接发送的,因此它必须尽可能小.为了缩小可执行文件,我依靠两种技术:

I had to do this many years ago with VC6. It was necessary because the executable was going to be transmitted over the wire to a target computer, where it would run. Since it was likely to be sent over a modem connection, it needed to be as small as possible. To shrink the executable, I relied on two techniques:

  1. 请勿使用C或C ++运行时.告诉编译器不要链接它们.使用Windows API的子集实现所有必要的功能,保证该子集当时可以在所有Windows版本上使用(98,Me,NT,2000).
  2. 告诉链接器将所有代码段和数据段组合为一个.我不记得要这样做的开关,也不知道它是否仍然可行,尤其是对于64位可执行文件.

最终的可执行文件大小:〜2K

The final executable size: ~2K

这篇关于适用于最小可执行文件的C ++ Windows编译器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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