clang Command Examples

Compile C, C++, and Objective-C source files. Can be used as a drop-in replacement for GCC. Part of LLVM. More information: https://clang.llvm.org/docs/ClangCommandLineReference.html.

clang {{path/to/source1.c path/to/source2.c ...}} {{-o|--output}} {{path/to/output_executable}}

clang {{path/to/source.c}} -Wall {{-o|--output}} {{output_executable}}

clang {{path/to/source.c}} -Wall {{-g|--debug}} -Og {{-o|--output}} {{path/to/output_executable}}

clang {{path/to/source.c}} {{-o|--output}} {{path/to/output_executable}} -I{{path/to/header}} -L{{path/to/library}} -l{{library_name}}

clang {{-S|--assemble}} -emit-llvm {{path/to/source.c}} {{-o|--output}} {{path/to/output.ll}}

clang {{-c|--compile}} {{path/to/source.c}}

clang {{path/to/source.c}} -O{{1|2|3|fast}} {{-o|--output}} {{path/to/output_executable}}

clang --version