TinyCC includes an integrated linker that can directly output relocatable ELF files, executable files, and dynamic libraries without relying on an external linker. This self-contained approach makes TCC uniquely portable and fast.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/TinyCC/tinycc/llms.txt
Use this file to discover all available pages before exploring further.
Output file generation
TCC can directly generate multiple output formats without external tools.ELF file generation
TCC can directly output relocatable ELF files (object files), executable ELF files, and dynamic ELF libraries without an external linker.
PE-i386 file generation (Windows)
TCC for Windows supports native Win32 executable formats:For detailed Windows usage information, see
tcc-win32.txt in the TCC distribution.Linking behavior
Library linking
TCC linker eliminates unreferenced object code in libraries:Library linking order example
Library linking order example
File types
TCC can load multiple input formats:- ELF object files (
.o) - Archives (
.afiles) - static libraries - Dynamic libraries (
.sofiles on Unix,.dllon Windows) - Assembly files (
.sand.S) - C source files (
.c)
Output format options
TCC supports multiple output formats through linker options.ELF variants
The binary output format is useful for embedded systems, bootloaders, and firmware where you need a raw binary image without ELF headers.
Linker options
Basic options
Output control
Output control
Library paths and linking
Library paths and linking
Advanced linker options
These options are passed to the linker with-Wl, prefix:
Windows-specific options
GNU Linker Scripts
TCC’s linker supports a subset of GNU ld scripts. This is necessary because many Linux systems use linker scripts for dynamic libraries (like
/usr/lib/libc.so).Supported commands
GROUP command
GROUP command
Group multiple libraries together:This allows using both shared and static libraries together.
FILE command
FILE command
Specify individual files:
OUTPUT_FORMAT and TARGET (ignored)
OUTPUT_FORMAT and TARGET (ignored)
These commands are recognized but ignored:
Position Independent Code (PIC)
Practical examples
Building a complete application
Advanced linking scenarios
Plugin system with dlopen
Plugin system with dlopen
-rdynamic flag exports symbols so plugins can access them via dlopen().Embedded/bare metal
Embedded/bare metal
Platform support
Linker capabilities by platform:| Platform | Object Files | Executables | Shared Libs | Notes |
|---|---|---|---|---|
| Linux i386 | ELF32 | Yes | Yes | Full support |
| Linux x86_64 | ELF64 | Yes | Yes | Full support |
| Windows i386 | PE | EXE/DLL | DLL | Full support |
| Windows x86_64 | PE+ | EXE/DLL | DLL | Full support |
| ARM | ELF32 | Yes | Yes | Supported |
| ARM64 | ELF64 | Yes | Yes | Supported |
| RISC-V | ELF64 | Yes | Yes | Supported |