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.

Advertisements

One thought on “Creating Tiny Windows executables with TCC”

Leave a Reply

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

WordPress.com Logo

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

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s