Invoking the compiler

The compiler invocation commands perform all necessary steps to compile C or C++ source files, assemble any .s and .S files, and link the object files and libraries into an executable program.

To compile a source program, use the basic invocation syntax shown below:
Read syntax diagramSkip visual syntax diagram
        (1)                
>>-+---------xlc-------+---------------------------------------->
   |  (2)              |   
   '-------+-xlC---+---'   
           '-xlc++-'       

   .-----------------------------------------.   
   | .---------------------.                 |   
   V V                     |                 |   
>------+-----------------+-+----input_file---+-----------------><
       '-compiler_option-'                       

Notes:
  1. Basic invocation to compile C source code
  2. Basic invocations to compile C++ source code

For most applications, you should compile with xlc, xlc++, or a thread safe counterpart. You can use xlc++ to compile either C or C++ program source, but compiling C++ files with xlc may result in link or run time errors because libraries required for C++ code are not specified when the linker is called by the C compiler.

Additional invocation commands are available to meet specialized compilation needs, primarily to provide explicit compilation support for different levels and extensions of the C or C++ language. See Invoking the compiler for more information about compiler invocation commands available to you, including special invocations intended to assist developers migrating from a GNU compilation environment to XL C/C++.