Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/santerijps/small-c-executables

Tutorial: How to generate small C executables
https://github.com/santerijps/small-c-executables

Last synced: 2 days ago
JSON representation

Tutorial: How to generate small C executables

Awesome Lists containing this project

README

        

# Tutorial: Small C Executables

1. Provide optimizing flags to your C compiler
2. Use a nexecutable compressor (`UPX` used in these examples)

or if possible, use `TCC`.

## Cross platform compilation

```shell
gcc -Os -s -fno-ident -fno-asynchronous-unwind-tables -o out.exe hello_crossplatform.c
upx --best --lzma --ultra-brute -f --compress-icons=3 --8-bit --no-reloc --no-align -q -o out.compressed.exe out.exe
```

### With `TCC`

```shell
tcc -o out.exe hello_crossplatform.c
```

## Native compilation (Windows)

```shell
gcc -Os -s -fno-ident -fno-asynchronous-unwind-tables -nostdlib -o out.exe C:\Windows\System32\kernel32.dll hello_native.c
```