How can I compile C files into an executable (.exe) file?

后端 未结 4 1310
予麋鹿
予麋鹿 2021-01-19 19:35

I am unsure about compiling C files into executables by using Cygwin under Windows 7.

Can anyone please tell me how to do this?

I\'ve read some tutorials but

相关标签:
4条回答
  • 2021-01-19 20:11

    For the beginning I would say it is enough to Install MinGW. If you have installed it you find in the bin folder a gcc.exe which is the Compiler. Either set the PATH Variable to the bin folder or go directly to this folder. In terminal use:

      gcc your_C_file.c
    

    The output will be an exe.

    0 讨论(0)
  • 2021-01-19 20:13

    Q: How can i compile c-files into an executable (.exe) file?

    A: Get and use a C compiler.

    GCC/Cygwin is one possibility. MS Visual Studio is another: you can download the free "MSVS Express" here: http://www.microsoft.com/visualstudio/en-us/products/2010-editions/express.

    How you interact with the compiler is another question.

    You can certainly use a command line.

    You can use a command line with or without "Make": you can let "Makefiles" do the "heavy lifting" for you, you can use .bat files, or you can type everything by hand.

    Using a graphical IDE is another possibility. "Eclipse" and "MS Visual Studio" are two popular alternatives for Windows.

    0 讨论(0)
  • 2021-01-19 20:14

    Even easier solution is A86 Assembler. Its old school but works perfectly, in the right hands ;)

    0 讨论(0)
  • 2021-01-19 20:32

    There are several ways to compile c-files. Makefiles are just one possibility. But as you proposed it... Here are two tutorials for Makefiles:

    1. http://makepp.sourceforge.net/1.19/makepp_tutorial.html
    2. http://mrbook.org/tutorials/make/ (Content from 2012 accessable via waybackmachine)

    But note, that you will also need a compiler (installed under cygwin).

    Another possibility is to use Dev-C++, a IDE (Integrated Developement Environment) for C++. Once installed you can create a project and add your source code, and just compile the project. It also contains a c++ compiler (also supports C), which is named mingw. The makefile needed is automatically generated. So that's simpler for beginners.

    You can download Dev-Cpp here: http://www.bloodshed.net/devcpp.html

    Note: As you spoke about cygwin I assume you use Windows. Dev++ works only under windows, and you wont need cygwin.

    0 讨论(0)
提交回复
热议问题