如何在 Windows 命令提示符下使用 Dev C++ 编译器编译 c++ 程序

How to compile a c++ program using Dev C++ compiler in windows command prompt?

本文关键字:C++ Dev 编译器 编译 程序 c++ Windows 命令提示符      更新时间:2023-10-16

我在Windows中安装了Dev C++,并使用了该IDE,但是我想在Windows命令提示符下编译我的程序prog1.cpp。我在当前目录中打开了cmd,并尝试了以下命令不起作用:

  1. CL 计划1.cpp
  2. CC 程序 1.cpp
  3. GCC Prog1 Prog1.cpp
  4. g++ -o prog1 prog1.cpp
  5. C 程序 1.cpp
  6. cl/EHsc prog1.cpp

上述所有命令都会导致此错误:command not recognized as an internal or external command, operable program or batch file.

注意:我不想安装 Visual Studio 并使用cl /EHsc prog1.cpp

使用 Dev C++编译器在 cmd 中编译程序的命令是什么?

Dev-C++ 不是编译器。这是一个 IDE。

您需要先将路径添加到编译器,然后才能使用它们。

假设您安装了 Dev-C++ 到 C:Program FilesDev-Cpp ,那么您需要将以下路径添加到变量%PATH%

C:Program FilesDev-CppMinGW64bin
C:Program FilesDev-CppMinGW64libexecgccmingw326.3.0
C:Program FilesDev-CppMinGW64mingw32bin

您可以将其临时添加到一个命令提示符会话中

path %PATH%;<more paths here>

或者参考谷歌了解如何将其永久添加到您的系统中。

解决%PATH%问题后,您将能够使用 gcc (C( 或 g++ (C++( 编译程序。请注意,ccl 仍然不可用(因为它们未安装(。