cl
símbolo del sistema, ingrese y verifique que la salida se vea algo como esto:In the command prompt window, enter cl
and verify that the output looks something like this:cl
error C1034 o error LNK1104 al ejecutar el comando, entonces no está utilizando un símbolo del sistema para desarrolladores o algo está mal con la instalación de Visual C++.If you get an error such as 'cl' is not recognized as an internal or external command, operable program or batch file,' error C1034, or error LNK1104 when you run the cl
command, then either you are not using a developer command prompt, or something is wrong with your installation of Visual C++.Debe solucionar este problema antes de poder continuar.You must fix this issue before you can continue.cl
para desarrolladores, o si recibe un mensaje de error al escribir , la instalación de Visual C++ puede tener un problema.If you can't find the developer command prompt shortcut, or if you get an error message when you enter cl
, then your Visual C++ installation may have a problem.Intente reinstalar el componente Visual C++ en Visual Studio o vuelva a instalar las herramientas de compilación de Microsoft Visual C++.Try reinstalling the Visual C++ component in Visual Studio, or reinstall the Microsoft Visual C++ Build Tools.No vaya a la siguiente sección cl
hasta que el comando funcione.Don't go on to the next section until the cl
command works.Para obtener más información acerca de la instalación y solución de problemas de Visual C++, vea Instalar Visual Studio.For more information about installing and troubleshooting Visual C++, see Install Visual Studio.md c:hello
símbolo del sistema para cd c:hello
desarrolladores, escriba para crear un directorio y, a continuación, escriba para cambiar a ese directorio.In the developer command prompt window, enter md c:hello
to create a directory, and then enter cd c:hello
to change to that directory.Este directorio es donde se crean el archivo de origen y el programa compilado.This directory is where your source file and the compiled program are created in.notepad hello.cpp
en la ventana del símbolo del sistema.Enter notepad hello.cpp
in the command prompt window.dir
en el símbolo del sistema para enumerar el contenido del directorio c:-hello.Enter dir
at the command prompt to list the contents of the c:hello directory.Debería ver el archivo de origen hello.cpp en la lista de directorios, que tiene un aspecto similar a:You should see the source file hello.cpp in the directory listing, which looks something like:.cpp
guardado el código .txt
fuente con una extensión de nombre de archivo, no con una extensión.Also make sure that you saved the source code with a .cpp
file name extension, not a .txt
extension.cl /EHsc hello.cpp
sistema para desarrolladores, escriba para compilar el programa.At the developer command prompt, enter cl /EHsc hello.cpp
to compile your program.hello
.To run the hello.exe program, at the command prompt, enter hello
.cl /EHsc file1.cpp file2.cpp file3.cpp
/EHsc
opción de línea de comandos indica al compilador que habilite el comportamiento estándar de control de excepciones C++.The /EHsc
command-line option instructs the compiler to enable standard C++ exception handling behavior.Sin él, las excepciones producidas pueden dar lugar a objetos no destruidos y fugas de recursos.Without it, thrown exceptions can result in undestroyed objects and resource leaks.Para obtener más información, consulte /EH (Modelo de control de excepciones).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 /?
lista rápida, escriba en el símbolo del sistema para desarrolladores.For a quick list, enter cl /?
at the developer command prompt.También puede compilar y vincular por separado y aplicar opciones de vinculador en escenarios de compilación más complejos.You can also compile and link separately and apply linker options in more complex build scenarios.Para obtener más información sobre las opciones y el uso del compilador y del vinculador, consulte Referencia de creación de C/C++.For more information on compiler and linker options and usage, see C/C++ Building Reference..c
trata los archivos que terminan .cpp
como código fuente de C y los archivos que terminan como código fuente de C++.By default, the MSVC compiler treats files that end in .c
as C source code, and files that end in .cpp
as C++ source code.Para forzar al compilador a tratar todos los archivos como C++ independientemente de la extensión de nombre de archivo, utilice la opción del compilador /TP.To force the compiler to treat all files as C++ independent of file name extension, use the /TP compiler option.