About
Clang compiles C, C++ and related languages. Termux recommends it over GCC. Use it to build from source, run experiments, or catch mistakes early through readable diagnostics.
Install it
pkg install clang
Run this inside Termux. If the package is already present, pkg will say so and
do nothing.
Commands worth knowing
6 of the invocations you will actually reach for. Tap the copy button to put one on your clipboard.
clang hello.c -o hello Compile a C source file into an executable named by the output flag. clang -Wall hello.c -o hello Compile with the common warning set turned on, so likely mistakes get reported. clang hello.c Compile and link without naming an output. This produces the default a.out file. clang -c hello.c Compile to an object file without linking. The first stage of a larger build. clang -g hello.c -o hello Include debugging information, so a debugger can show source lines. clang --version Print the compiler version. Useful when a build script checks for one. Worked example
Run clang -Wall broken.c and this is what you should see.
$ clang -Wall broken.c
broken.c:4:14: error: expected ';' after expression
return x + y
^
;
1 error generated. The caret points at the exact column the parser stumbled on.
Developed by
The LLVM Project .