5
|
1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
|
2 |
<html lang="en">
|
|
3 |
|
|
4 |
<head>
|
|
5 |
<meta http-equiv="Content-Language" content="en-us">
|
|
6 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
7 |
<title>Creating your makefile</title>
|
|
8 |
<link rel="stylesheet" type="text/css" href="../help.css">
|
|
9 |
<script language="JavaScript">
|
|
10 |
function newWin(url) {
|
|
11 |
window.open(url, 'install_cdt', 'width=750, height=700, menubar=no, toolbar=no, status=no, resizable=yes, location=no, scrollbars=yes');
|
|
12 |
}
|
|
13 |
</script>
|
|
14 |
</head>
|
|
15 |
|
|
16 |
<body>
|
|
17 |
|
|
18 |
<h1>Creating a makefile</h1>
|
|
19 |
|
|
20 |
<p>For the purpose of this tutorial, you were instructed to create a C++ Project which requires you to create a makefile.</p>
|
|
21 |
|
|
22 |
<p>To create a makefile:</p>
|
|
23 |
<ol>
|
|
24 |
<li>In the <b>Project Explorer</b> view, right-click the <b>HelloWorld</b> project
|
|
25 |
folder and select <b>New > File</b>.
|
|
26 |
<li>In the <b>File name</b> box, type <b>makefile</b>.</li>
|
|
27 |
<li>Click <b>Finish</b>.</li>
|
|
28 |
<li>Type the gnu make instructions below in the editor. Lines are
|
|
29 |
indented with tab characters, not with spaces.</li>
|
|
30 |
|
|
31 |
<blockquote>
|
|
32 |
<p>
|
|
33 |
<br>
|
|
34 |
all: hello.exe<br>
|
|
35 |
<br>
|
|
36 |
clean:<br>
|
|
37 |
rm main.o hello.exe<br>
|
|
38 |
<br>
|
|
39 |
hello.exe: main.o<br>
|
|
40 |
g++ -g -o hello main.o<br>
|
|
41 |
<br>
|
|
42 |
main.o:<br>
|
|
43 |
g++ -c -g main.cpp<br>
|
|
44 |
</p>
|
|
45 |
</blockquote>
|
|
46 |
<li>Click <b>File >
|
|
47 |
Save</b>.</li></ol>
|
|
48 |
|
|
49 |
<p>Your new makefile, along with your main.cpp file are
|
|
50 |
displayed in the Project Explorer view. Your project now
|
|
51 |
contains main.cpp and makefile. You can now build your HelloWorld project.</p>
|
|
52 |
|
|
53 |
|
|
54 |
<p>NEW <a href="javascript:void(0)" onClick="newWin('../images/cdt_w_newmake02.png')">Click here to see an illustration</a>.</p>
|
|
55 |
|
|
56 |
<p>
|
|
57 |
<a href="cdt_w_build.htm" style="text-decoration: none">
|
|
58 |
<img border="0" src="../images/ngnext.gif" width="16" height="16" alt="Next icon"></a>
|
|
59 |
<b><a href="cdt_w_build.htm">
|
|
60 |
Next: Building your project</a><a href="cdt_w_build.htm" style="text-decoration: none"> </a> </b>
|
|
61 |
</p>
|
|
62 |
<p align="left">
|
|
63 |
|
|
64 |
<a href="cdt_w_newcpp.htm">
|
|
65 |
<img border="0" src="../images/ngback.gif" width="16" height="16" alt="Back icon"></a> <b><a href="cdt_w_newcpp.htm">Back: Creating your C++ file</a></b> </p>
|
|
66 |
<p><img border="0" src="../images/ngconcepts.gif" ALT="Related concepts" width="143" height="21">
|
|
67 |
<br>
|
|
68 |
<a href="../concepts/cdt_o_projects.htm">Project</a><br>
|
|
69 |
<a href="../concepts/cdt_o_code_entry.htm">Code entry</a></p>
|
|
70 |
<p><img border="0" src="../images/ngtasks.gif" ALT="Related tasks" width="143" height="21">
|
|
71 |
<br>
|
|
72 |
<a href="../tasks/cdt_o_proj_files.htm">Working with C/C++ project files</a><br>
|
|
73 |
<a href="../tasks/cdt_o_write_code.htm">Writing code</a></p>
|
|
74 |
<p><img border="0" src="../images/ngref.gif" ALT="Related reference" width="143" height="21">
|
|
75 |
<br>
|
|
76 |
<a href="../reference/cdt_o_proj_prop_pages.htm">C/C++ Projects view</a></p>
|
|
77 |
|
|
78 |
<p>
|
|
79 |
<img src="../images/ng00_04a.gif" ALT="IBM Copyright Statement" >
|
|
80 |
</body>
|
|
81 |
|
|
82 |
</html> |