Compiling and Linking Multithread Programs
| Overview | How Do I | Sample
To compile and link the multithread program BOUNCE.C from within the development environment
Click New on the File menu, then click the Projects tab.
On the Projects tab, click Console Application, and name the project.
Add the file containing the C source code to the project.
On the Project menu, click Settings. In the Project Settings dialog box, click the C/C++ tab. Select Code Generation from the Category drop-down list box. From the Use Run-Time Library drop-down box, select Multithreaded. Click OK.
Build the project by clicking the Build command on the Build menu.
To compile and link the multithread program BOUNCE.C from the command line
Ensure that the Win32 library files and LIBCMT.LIB are in the directory specified in your LIB environment variable.
Compile and link the program with the CL command-line option /MT:
CL /MT BOUNCE.C
If you choose not to use the /MT option, you must take these steps:
Define the _MT symbol before including header files. You can do this by specifying
/D _MT
on the command line.Specify the multithread library and suppress default library selection.
The multithread include files are used when you define the symbolic constant _MT. You can do this with the CL command line option
/D _MT
or within the C source file before any include statements, as follows:#define _MT #include <stdlib.h>