Quick start
This guide will get you up and running with TinyCC in just a few steps. You’ll learn how to compile and run C programs using TCC’s unique direct execution feature.Before starting, make sure you have installed TinyCC on your system.
Your first TCC program
Let’s create and run a simple “Hello World” program using TCC.1
Create a C source file
Create a file named
hello.c with the following content:hello.c
2
Compile and run directly
TCC’s killer feature is the ability to compile and execute in one step:Output:
3
Create an executable (optional)
If you want to create a standalone executable:This creates a binary file named
hello that you can run anytime.TCC as a C script interpreter
One of TCC’s most powerful features is C scripting support. You can run C code like a shell script!1
Create a C script
Create a file named The first line is a shebang that tells your shell to use TCC to run the file.
hello_script.c:hello_script.c
2
Make it executable
Set the execute permission:
3
Run it directly
Now you can run it like any shell script:Output:
If TCC is installed in a different location on your system, adjust the shebang path accordingly. Use
which tcc to find the correct path.Working with command line arguments
C scripts can accept command line arguments just like any other program:args_demo.c
Compiling multiple files
TCC can compile and link multiple C files together:1
Create a utility module
Create And its header
utils.c:utils.c
utils.h:utils.h
2
Create the main program
Create
main.c:main.c
3
Compile and run
Compile both files together:Output:
Using TinyCC’s built-in library
TCC includes a minimal librarytcclib.h that’s perfect for small programs or systems without standard headers:
minimal.c
Compiling from stdin
TCC can read and compile C code from standard input, which is great for one-liners and testing:Common compilation patterns
Comparing TCC with GCC
Here’s how TCC commands compare to GCC:Benchmarking compilation speed
See the difference in compilation speed:-O0 (no optimization).
Next steps
Command line reference
Learn about all TCC command line options and flags
C scripting guide
Master advanced C scripting techniques with TCC
libtcc API
Use TCC as a library for dynamic code generation
Features
Explore TCC features and capabilities