makefile extension

后端 未结 8 1094
遥遥无期
遥遥无期 2021-02-08 09:29

I\'m writing a C program using gcc in cygwin. My question is, how do you create a makefile? I mean, what file-extension does it have? I know how to write simple rules, but I can

8条回答
  •  走了就别回头了
    2021-02-08 10:19

    Open your favorite text editor, and create a file named Makefile.

    Content might vary, but, provided you have a program called hello.c a very, very simple Makefile to compile it could be:

    hello: hello.c
         gcc -Wall hello.c -o hello.exe
    

    After that you run run from cygwin shell:

    $ ls
    hello.c Makefile
    $ make
    ....
    

    And your Makefile will try to compile hello.c. If everything goes as expected, you can run the hello.exe program by executing the following shell command:

    $ ./hello.exe
    

    Here's a nice tutorial on Makefiles.

提交回复
热议问题