Is there a way to write a target to
1) only create object files?
2) only to link object files and create the binary file?
I would like to be able create my binary file in 2 steps.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is an implicit rule for that. Let’s say you have the following Makefile:
If you only want the object file, then you just need to run:
And you will get the object file. However, you can also write an explicit rule, such as:
The previous rule is a rule to build from any
.cfile to an object (.o) file.$<helps to get the name of file where the rule depends on.If you have several objects files, you might want to define variables then:
In this case,
objectsis a variable associated with the object files you want to compile. Which is used in the ruleclientas a dependency and as argument to link them, it is also used to define rules that depends on header files (config.hin this example), and finalle is used in thecleanrule to delete them to start all over again.$@is a replacement for the name of the rule. In the last case it would beclient.The manual of GNU Make contains a lot of examples that should enlighten your learn process.