<p>A makefile is a text file that is referenced by the make command that describes the building of targets, and contains information such as source-level dependencies and build-order dependencies. </p>
<p>The CDT can generate a makefile for you, such projects are called Managed Make projects. Some projects, known as Standard Make projects, allow you to define your own makefile.</p>
Your Console view can be very useful for debugging a build.
<p><fontsize="+1"><b>Q1</b>. My Console view says <tt>“Error launching builder��?</tt>. What does that mean?<p></font>
<pre>
Error launching builder (make –k clean all )
(Exec error:Launching failed)
</pre>
<p>Most probably, the build command (by default “make��?) is not on your path. You can put it on your path and restart Eclipse.<br>
You can also change the build command to something that is on your path. If you are using MinGW tools to compile, you should replace the build command with “mingw32-make��?.</p>
<p><fontsize="+1"><b>Q2</b>. My Console view says <tt>“No rule to make target ‘X’��?</tt>.</p></font>
<pre>
make -k clean all
make: *** No rule to make target `clean'.
make: *** No rule to make target `all'.
</pre>
<p>By default, the make program looks for a file most commonly called “Makefile��? or “makefile��?. If it cannot find such a file in the working directory, or if that file is empty or the file does not contain rules for the command line goals (“clean��? and “all��? in this case), it will normally fail with an error message similar to those shown. </p>
<p>If you already have a valid Makefile, you may need to change the working directory of your build. The default working directory for the build command is the project’s root directory. You can change this by specifying an alternate Build Directory in the Make Project properties.
Or, if your Makefile is named something else (eg. <tt>buildFile.mk</tt>), you can specify the name by setting the default Build command to <tt>make –f buildFile.mk</tt>.</p>
<p>If you do not have a valid Makefile, create a new file named Makefile in the root directory. You can then add the contents of the sample Makefile (above), and modify it as appropriate.</p>
<p><fontsize="+1"><b>Q3</b>. My Console view says <tt>“missing separator��?</tt>.</p></font>
<pre>
make -k clean all
makefile:12: *** missing separator. Stop.
</pre>
<p>The standard syntax of Makefiles dictates that every line in a build rule must be preceded by a Tab character. This Tab character is often accidentally replaced with spaces, and because both result in white-space indentation, this problem is easily overlooked. In the sample provided, the error message can be pinpointed to line 12 of the file “makefile��?; to fix the problem, insert a tab at the beginning of that line.</p>
<p><fontsize="+1"><b>Q4</b>. My Console view says <tt>"Target `all' not remade because of errors"</tt>.</p></font>
<pre>
make -k clean all
make: *** [clean] Error 255
rm -f Test1.o Test2.o Main.o test_me.exe
g++ -g -o Test1.o -c Test1.cpp
make: *** [Test1.o] Error 255
make: *** [Test2.o] Error 255
make: *** [Main.o] Error 255
g++ -g -o Test2.o -c Test2.cpp
g++ -g -o Main.o -c Main.cpp
make: Target `all' not remade because of errors.
</pre>
<p>The likely culprit here is that g++ is not on your Path.<br>
<p>The Error 255 is produced by make as a result of its command shell not being able to find a command for a particular rule.<br>
Messages from the standard error stream (the lines saying Error 255) and standard output stream (all the other lines) are merged in the Console view here.</p>
<p><fontsize="+1"><b>Q5</b>. What's with the -k flag?</p></font>
<p>The -k flag tells make to continue making other independent rules even when one rule fails.
This is helpful for build large projects.</p>
<p>You can remove the -k flag by turning on Project Properties > C/C++ Make Project > Make Builder > Stop on first build error</p>
make (e=2): The system cannot find the file specified.
mingw32-make: *** [clean] Error 2
rm -f Test1.o Test2.o Main.o test_me.exe
</pre>
<p>This means that mingw32-make was unable to find the utility "rm". Unfortunately, MinGW does not come with "rm". To correct this, replace the clean rule in your Makefile with:</p>
<p>The leading minus sign tells make to consider the clean rule to be successful even if the del command returns failure. This may be acceptable since the del command will fail if the specified files to be deleted do not exist yet (or anymore).</p>