cl
and verify that the output looks something like this:cl
command, then either you are not using a developer command prompt, or something is wrong with your installation of Visual C++. You must fix this issue before you can continue.cl
, then your Visual C++ installation may have a problem. Try reinstalling the Visual C++ component in Visual Studio, or reinstall the Microsoft Visual C++ Build Tools. Don't go on to the next section until the cl
command works. For more information about installing and troubleshooting Visual C++, see Install Visual Studio.md c:hello
to create a directory, and then enter cd c:hello
to change to that directory. This directory is where your source file and the compiled program are created in.notepad hello.cpp
in the command prompt window.dir
at the command prompt to list the contents of the c:hello directory. You should see the source file hello.cpp in the directory listing, which looks something like:.cpp
file name extension, not a .txt
extension.cl /EHsc hello.cpp
to compile your program.hello
.cl /EHsc file1.cpp file2.cpp file3.cpp
/EHsc
command-line option instructs the compiler to enable standard C++ exception handling behavior. Without it, thrown exceptions can result in undestroyed objects and resource leaks. For more information, see /EH (Exception Handling Model).cl /EHsc file1.cpp file2.cpp file3.cpp /link /out:program1.exe
cl /W4 /EHsc file1.cpp file2.cpp file3.cpp /link /out:program1.exe
cl /?
at the developer command prompt. You can also compile and link separately and apply linker options in more complex build scenarios. For more information on compiler and linker options and usage, see C/C++ Building Reference..c
as C source code, and files that end in .cpp
as C++ source code. To force the compiler to treat all files as C++ independent of file name extension, use the /TP compiler option.