What is the difference between make and gcc?

前端 未结 11 1314
小鲜肉
小鲜肉 2021-01-31 02:39

The last sentence in the article caught my eye

[F]or C/C++ developers and students interested in learning to program in C/C++ rather than users of L

相关标签:
11条回答
  • 2021-01-31 03:32

    gcc compiles and/or links a single file. It supports multiple languages, but does not knows how to combine several source files into a non-trivial, running program - you will usually need at least two invocations of gcc (compile and link) to create even the simplest of programs.

    Wikipedia page on GCC describes it as a "compiler system":

    The GNU Compiler Collection (usually shortened to GCC) is a compiler system produced by the GNU Project supporting various programming languages.

    make is a "build tool" that invokes the compiler (which could be gcc) in a particular sequence to compile multiple sources and link them together. It also tracks dependencies between various source files and object files that result from compilation of sources and does only the operations on components that have changed since last build.

    GNUmake is one popular implementation of make. The description from GNUmake is as follows:

    Make is a tool which controls the generation of executables and other non-source files of a program from the program's source files.

    Make gets its knowledge of how to build your program from a file called the makefile, which lists each of the non-source files and how to compute it from other files.

    0 讨论(0)
  • 2021-01-31 03:32

    'gcc' is the compiler - the program that actually turns the source code into an executable. You have to tell it where the source code is, what to output, and various other things like libraries and options.

    'make' is more like a scripting language for compiling programs. It's a way to hide all the details of compiling your source (all those arguments you have to pass the compiler). You script all of the above details once in the Makefile, so you don't have to type it every time for every file. It will also do nifty things like only recompile source files that have been updated, and handle dependancies (if I recompile this file, I will then need to recompile THAT file.)

    0 讨论(0)
  • 2021-01-31 03:34

    Make often uses gcc to compile a multitude of C or C++ files.

    0 讨论(0)
  • 2021-01-31 03:34

    You can use make to compile your C and C++ programs by calling gcc or g++ in your makefile to do all the compilation and linking steps, allowing you to do all these steps with one simple command. It is not a replacement for the compiler.

    0 讨论(0)
  • 2021-01-31 03:37

    make uses a Makefile in the current directory to apply a set of rules to its input arguments. Make also knows some default rules so that it executes even if it doesn't find a Makefile (or similar) file in the current directory. The rule to execute for cpp files so happens to call gcc on many systems.

    Notice that you don't call make with the input file names but rather with rule names which reflect the output. So calling make xyz will strive to execute rule xyz which by default builds a file xyz (for example based on a source code file xyz.cpp.

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