Home | Overview | How Do I | Compiler Options
CL automatically invokes the linker after compiling unless the /c option is used. CL passes to the linker the names of .OBJ files created during compiling and the names of any other files specified on the command line. The linker uses the options listed in the LINK environment variable. You can use the /link option to specify linker options on the CL command line. Options that follow the /link option override those in the LINK environment variable. The options in the following table suppress linking.
Option | Description |
/c | Compile without linking |
/E, /EP, /P | Preprocess without compiling or linking |
/Zg | Generate function prototypes |
/Zs | Check syntax |
For further details about linking, see Linker Option Reference.
Assume that you are compiling three C source files: MAIN.C, MOD1.C, and MOD2.C. Each file includes a call to a function defined in a different file:
func1
in MOD1.C and the function func2
in MOD2.C.myline
and mycircle
, which are defined in a library named MYGRAPH.LIB
.To build this program, compile with the following command line:
CL MAIN.C MOD1.C MOD2.C MYGRAPH.LIB
CL first compiles the C source files and creates the object files MAIN.OBJ, MOD1.OBJ, and MOD2.OBJ. The compiler places the name of the standard library in each .OBJ file. For more details, see Use Run-Time Library.
CL passes the names of the .OBJ files, along with the name MYGRAPH.LIB
, to the linker. The linker resolves the external references as follows:
func1
is resolved using the definition in MOD1.OBJ; the reference to func2
is resolved using the definition in MOD2.OBJ.myline
and mycircle
are resolved using the definitions in MYGRAPH.LIB
.