I'm new to C, and I understand that both of those commands accomplish the same thing, but does one of them do something different than the other along the way?
First of all, if you are using
make then for
hello.c you will call make as
make hello and not
make hello.c. Also, note that
make is most of the times used with a
Makefile. Nonetheless, you can build executable binary from single source file using
make as you have shown.
make will run the build commands only if it thinks that the source code has changed after last build, whereas
cc will always do the build.
$ make hello cc hello.c -o hello $ make hello make: 'hello' is up to date. # Make does not think source file has changed $ touch hello.c # Update the timestamp of hello.c $ make hello cc hello.c -o hello # Make thinks source file changed. Builds again $
cc will not check if the source has changed or not. It will always do the required build.
$ cc hello.c -o hello $ ls -l hello | cut -d ' ' -f '8-' 12:18 hello $ cc hello.c -o hello # Build again without changing source $ ls -l hello | cut -d ' ' -f '8-' 12:21 hello # hello was built again $
Above description was for
GNU make and
GNU cc. Not sure about other implementations.