Skip to main content
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.

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:
Important limitation: The linker does a single pass on object and library lists. Order matters! Libraries should come after the object files that use them. Grouping options (--start-group and --end-group) are not supported.

File types

TCC can load multiple input formats:
  • ELF object files (.o)
  • Archives (.a files) - static libraries
  • Dynamic libraries (.so files on Unix, .dll on Windows)
  • Assembly files (.s and .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

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 multiple libraries together:
This allows using both shared and static libraries together.
Specify individual files:
These commands are recognized but ignored:

Position Independent Code (PIC)

Current limitation: TCC does not generate position independent code (PIC) for dynamic libraries. This means:
  • Dynamic library code generated by TCC cannot be shared among processes
  • Each process gets its own copy of the library code in memory
  • This may increase memory usage when multiple processes use the same TCC-compiled shared library

Practical examples

Building a complete application

Advanced linking scenarios

The -rdynamic flag exports symbols so plugins can access them via dlopen().

Platform support

Linker capabilities by platform:
For best cross-platform compatibility, stick to standard library linking and avoid platform-specific linker scripts when possible.