CL Invokes the Linker
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.
Compile without linking
/E, /EP, /P
Preprocess without compiling or linking
Generate function prototypes
For further details about linking, see Linker Options.
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:
MAIN.c calls the function func1 in MOD1.c and the function func2 in MOD2.c.
MOD1.c calls the standard library functions printf_s and scanf_s.
MOD2.c calls graphics functions named 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