Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 117 Vote(s) - 3.71 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using "make" C Programming (Learn C the Hard Way)

#1
<br><br>
I'm learning C Programming through "Learn C the Hard Way." I have am currently on Exercise 1, which can be found here:

[To see links please register here]


I understand the concept being covered, but don't understand the compiling process. While using the "make" command in the command line, why does this work:

$ make ex1

And this not work:

$ make ex1.c

I was actually just running the second command until a minute ago. I eventually figured it out though. Until I did, I kept getting this error message:

make: nothing to be done for 'ex1.c'

While this is a just a technicality, I would still like to know what's happening. Thanks :)
Reply

#2
The target to `make` usually specifies what you want it to build or rebuild, not what you want it to use to build something else.

If you type `ex1.c` (and there's no rule to auto-generate it), make essentially just answers "Yup, that file exists."
Reply

#3
Both work; they just do different tasks.

* `make ex1.c` says "using the rules in the makefile plus built-in knowledge, ensure that the file `ex1.c` is up to date".

The `make` program finds `ex1.c` and has no rules to build it from something else (no RCS or SCCS source code, for example), so it report 'Nothing to be done'.

* `make ex1` says "using the rules in the makefile plus built-in knowledge, ensure that the file `ex1` is up to date".

The `make` program finds that it knows a way to create an executable `ex1` from the source file `ex1.c`, so it ensures that the source file `ex1.c` is up to date (it exists, so it is up to date), and then makes sure the `ex1` is up to date too (which means 'file `ex1` was modified more recently than `ex1.c`). If you've edited `ex1.c` since you last ran `make`, it will do the compilation to make `ex1` newer than `ex1.c`. If the compilation fails, the file `ex1` won't exist, so you'll get another recompilation next time too. And once it is up to date, then `make` won't rebuild `ex1` again until you modify the source again.

This is the way `make` is designed to work.
Reply

#4
the argument to the `make` tool is the name of the executable file that it
will help create for you. It should not have a `.c` extension. You should have
written `make ex1` only.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through