如何通过Windows命令提示符编译C / C ++程序?

迄今为止,对于C / C ++编程语言,我已经使用Code :: blocks程序来编写和编译程序。 不过,我需要知道如何通过Windows命令提示编译程序,因为我需要访问创build的汇编代码。 我的编译器是mingw32-gcc.exe,mingw32-g ++。exe

请阅读使用MinGW编译程序 – 新用户指南 。 要使gcc生成汇编代码,请使用-S选项:

  -S Stop after the stage of compilation proper; do not assemble. The output is in the form of an assembler code file for each non-assembler input file specified. By default, the assembler file name for a source file is made by replacing the suffix .c, .i, etc., with .s. Input files that don't require compilation are ignored. 

祝你好运!

如果使用mingw作为gcc编译器安装了代码块,请按照下列步骤操作

  1. 右键点击我的电脑 – >进入属性 – >提前系统设置
  2. 然后创建一个名为PATH的环境变量,并粘贴完整的URL,如程序文件(x86)/ codeblocks / mingw / bin。
  3. 现在打开cmd
  4. 转到您的程序保存的目录。
  5. 键入gcc program_name.c -o program_name.exe来编译程序。
  6. 通过键入program_name运行该程序