How do I compile a C/C++ program through windows command prompt?

核能气质少年 提交于 2020-01-05 02:55:09

问题


Im new to the C/C++ programming language an so far have used the Code::blocks program for writing and compiling programs. However I need to know how to compile a program via windows command prompt as I need to access the assembly code created. My compilers are mingw32-gcc.exe, mingw32-g++.exe


回答1:


Please read Compile Programs with MinGW -- A Guide for New Users. To make gcc produce assembler code, use -S option:

   -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.

Good luck!




回答2:


if you have codeblocks installed with mingw as the gcc compiler then follow these steps

  1. Right click on my computer -> go to properties -> advance system settings
  2. Then make an environment variable named PATH and paste the complete url like program file (x86)/codeblocks/mingw/bin.
  3. now open cmd
  4. go to the directory where your program is saved.
  5. type gcc program_name.c -o program_name.exe to compile the program.
  6. run the program by typing program_name


来源:https://stackoverflow.com/questions/6281493/how-do-i-compile-a-c-c-program-through-windows-command-prompt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!