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
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
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
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
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
With
-E: output #define directives along with preprocessed code.With
-E: output only #define directives (no preprocessed code).Shared library commands
Generate a shared library instead of an executable.
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
Create the archive.
Replace or add files to the archive.
Create or update the archive symbol index.
List the contents of the archive.
Verbose output.
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
Display TCC version information.
Print only the version number.
Verbose output
Show included files during compilation. As sole argument, print search directories.
Show included files and all file search attempts.
Search paths
Print the configured installation directory and list of library and include directories that TCC will search.
Help commands
Display basic help message with common options.
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
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
Display compilation statistics including time and memory usage.