Synopsis
Basic compilation commands
Compile and link
Compile C source files and generate an executable:a.c and b.c, links them together, and generates the executable myprog.
Compile only
flag
Compile only - generate an object file without linking.
a.c and generates the object file a.o.
- C source
- Assembly with preprocessing
- Assembly without preprocessing
Link object files
Link object files together to create an executable:Generate relocatable object file
flag
Generate a relocatable object file by combining all input files.
a.c and b.c, links them together, and generates the relocatable object file ab.o.
Run command
flag
Compile source file(s) and run the resulting program immediately with optional command-line arguments.
Basic execution
Compile and execute a C program directly:With arguments
Pass arguments to the compiled program:arg1 and arg2 are passed to the main() function of a.c.
Multiple source files
Compile multiple files and execute them:a.c and b.c, links them together, and executes the resulting program with arg1 as the first argument.
With TCC options
You can pass TCC options after-run by enclosing them in quotes:
When using
-run, TCC compiles the code in memory and executes it immediately without creating an executable file on disk.Custom stdin
Redirect stdin for the running program:Preprocessing commands
flag
Preprocess only - output the preprocessed source to stdout or file (with
-o).Preprocessing options
- Standard preprocessing
- No line directives
- Alternative line directives
Show macro definitions
flag
With
-E: output #define directives along with preprocessed code.flag
With
-E: output only #define directives (no preprocessed code).Shared library commands
Generate a shared library instead of an executable.
string
Set the name for the shared library to be used at runtime.
Archive tool
TCC includes an integrated archiver for creating static libraries:Archive operations
flag
Create the archive.
flag
Replace or add files to the archive.
flag
Create or update the archive symbol index.
flag
List the contents of the archive.
flag
Verbose output.
flag
Extract files from the archive.
Examples
Import library tool (Windows)
On Windows, TCC can create import definition files from DLLs:.def file from a DLL:
Information commands
Version information
flag
Display TCC version information.
flag
Print only the version number.
Verbose output
flag
Show included files during compilation. As sole argument, print search directories.
flag
Show included files and all file search attempts.
Search paths
flag
Print the configured installation directory and list of library and include directories that TCC will search.
Help commands
flag
Display basic help message with common options.
flag
Display extended help with all options including warnings, flags, and linker options.
Input from stdin
TCC can read C source code from standard input:- character is used in place of the input filename to indicate stdin.
Response files
string
Read command-line arguments from a file. Each line in the file is treated as a separate argument.
compile_options.txt:
Response files are useful for very long command lines that might exceed shell limits.
Compilation statistics
flag
Display compilation statistics including time and memory usage.