Creating Tiny Windows executables with TCC

I recently compiled a small executable program writtern in C with the Visual Studio C++ Express. The output was a 56K executable, which ok is pretty small, but actually in terms of programs its really large.

So I looked into compiling my program with the TinyCC compiler.

First I downloaded the compiler, however it quickly came apparent that the libraries and includes that come with the compiler were just a minimal set. What I needed was the includes from MinGW. Its only necceccery to download the Windows 32 API package.

My program needed to be linked with winsock2 so first i needed to run

tiny_impdef c:windowssystem32ws2_32.dll

This will generate a ws2_32.def file. I was then able to simply compile the program with.

tcc program.c ws2_32.def

The output of which is an executable of 1K. I asume because the compiler itself is small, and the compiler compiles itself that it would produce rather small executables. I have yet to test compiling the same program using mingw and GCC -Os.


One thought on “Creating Tiny Windows executables with TCC”

  1. The smallest size for the same executable I have managed to compile using Mingw GCC was 5.5K

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s