carbidecpp22devenv/configuration/org.eclipse.osgi/bundles/309/1/.cp/concepts/cdt_c_build_over.htm
author cawthron
Fri, 04 Dec 2009 10:01:33 -0600
changeset 5 684bf18fdedf
permissions -rw-r--r--
add files for RCL_2_2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
     1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
     2
<html lang="en">
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
     3
<head>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
     4
  <meta http-equiv="Content-Language" content="en-us">
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
     5
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
     6
  <title>Building C/C++ projects</title>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
     7
  <link rel="stylesheet" type="text/css" href="../help.css">
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
     8
</head>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
     9
<body>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    10
<h1>Building C/C++ projects</h1>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    11
<p>The CDT relies on an external make utility, such as GNU make, to
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    12
build a project. The CDT can generate makefiles automatically when you
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    13
create a Managed Make C project or a Managed Make C++ project. You have
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    14
the option of creating a Standard Make C project or a Standard Make C++
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    15
project and providing the makefile yourself.</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    16
<h2>Required utilities</h2>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    17
<p>You must install and configure the following utilities:
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    18
</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    19
<ul>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    20
  <li>Build (e.g. make).</li>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    21
  <li>Compile (e.g. gcc).</li>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    22
  <li>Debug (e.g. gdb).</li>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    23
</ul>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    24
<b>Note: </b> while make, gcc and gdb are the examples used in the
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    25
documentation, virtually any similar set of tools or utilities could be
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    26
used.
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    27
<p></p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    28
<p><b>Tip: </b>Cygwin contains these utilities (make, gcc and gdb) for
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    29
a Windows environment.&nbsp; While running the cygwin installation,
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    30
ensure <tt>gcc</tt> and <tt>make</tt> are selected since they are not
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    31
installed by default. For more information, see <a
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    32
 href="http://www.cygwin.com">http://www.cygwin.com</a>. If you are a
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    33
Red Hat user, all that you need to do to build your project is included
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    34
in the Red Hat Linux installation.
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    35
For other operating systems, please refer to your installation
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    36
documentation.</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    37
<p></p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    38
<h2>Build terminology</h2>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    39
<p>The CDT uses a number of terms to describe the scope of the build. </p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    40
<h3>Build Project</h3>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    41
<p>This is an incremental build (make all, assuming all is defined in
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    42
your makefile). Only the components affected by modified files in that
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    43
particular project are built.</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    44
<h3>Rebuild Project</h3>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    45
<p>Builds every file in the project whether or not a file has been
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    46
modified since the last build. A rebuild is a clean followed by a build.</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    47
<p>For more information on builds, see:</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    48
<ul>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    49
  <li><b>Workbench User Guide &gt; Concepts &gt; Workbench &gt; Builds</b></li>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    50
  <li><b>Workbench User Guide &gt; Tasks &gt; Building resources</b></li>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    51
</ul>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    52
<p>Build-related information is displayed as follows:</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    53
<ul>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    54
  <li>The Console view displays the output of the build tools.</li>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    55
  <li>The Tasks view displays a list of compiler errors and warnings
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    56
related to your projects.</li>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    57
  <li>For Standard Make projects, the Makefile targets are displayed in
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    58
the Make Targets view.</li>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    59
</ul>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    60
<p>For more information about the Tasks view, see <b>Workbench User
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    61
Guide &gt; Reference &gt; User interface information &gt; Views and
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    62
editors &gt; Tasks view</b>.</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    63
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    64
<h2>Getting a makefile</h2>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    65
<p>You can either create a C/C++ project for which you supply the <b>makefile</b>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    66
or create a C/C++ project for which the CDT generates makefiles
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    67
automatically.</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    68
<p>To create a new project, from the menu bar choose <b>File &gt; New
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    69
&gt; Project</b>. In the dialog that appears, expand the C/C++ group
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    70
and choose e.g. C Project</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    71
<ul>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    72
  <li>In the resulting wizard page, to create a project for which you supply the <b>makefile</b>,
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    73
select  <b>Makefile project</b> and choose one of the alternatives under that.
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    74
An empty project, or a simple "Hello World"  can be created. 
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    75
You edit and manage the makefile yourself.
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    76
<p>&nbsp;</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    77
</li>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    78
  <li>To create a project for which the CDT supplies a basic <b>makefile</b>,
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    79
select another project type, e.g. <b>Executable</b> and choose one of the examples
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    80
under that, or choose <b>Empty Project</b>. 
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    81
</li>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    82
</ul>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    83
<h2>Setting build preferences</h2>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    84
<p>You can set build preferences in Eclipse:</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    85
<dl>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    86
  <dt>Build order</dt>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    87
  <dd>If certain projects must be built before others, you can set the <i>build
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    88
order</i>. If your project refers to another project, the CDT must
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    89
build the other project first. To set the build order, from the menu
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    90
bar select <b>Window &gt; Preferences</b> and choose <b> General > Preferences > Build Order</b>.
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    91
    <p>When you set the build order, the CDT does not rebuild projects
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    92
that depend on a project; you must rebuild all projects to ensure all
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    93
changes are propagated.</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    94
  </dd>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    95
  <dt>Automatic save</dt>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    96
  <dd>You can set the CDT to perform an <i>automatic save</i> of all
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    97
modified resources when you perform a manual build. In the preferences dialog, 
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    98
select <b>General > Workspace</b> and check <b>Save automatically before build</b>.
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    99
By default,
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   100
this feature is <i>not</i> enabled.</dd>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   101
</dl>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   102
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   103
<h2>Controlling the building of your project</h2>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   104
<p>For a Makefile project, the C/C++ compiler that a project uses
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   105
is controlled by the project's <b>Properties</b> setting.
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   106
To view a project's properties, right-click on the project and select <b>Properties</b>.
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   107
In the dialog that appears, the <b>C/C++ Build</b>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   108
page enables you to control a variety of settings, including:</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   109
<dl>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   110
	<dt>Build Command</dt>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   111
	<dd>On the <b>Builder Settings</b> tab, this controls which <code>make</code> is used. To change it, uncheck <b>Use
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   112
	default build command</b> and change it or add arguments to the make command.</dd>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   113
	
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   114
	<dt>Build Setting</dt>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   115
	<dd>On the <b>Behaviour</b> tab, this controls whether the compiler will <b>Stop on first build error</b> or not
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   116
	(keep going). Unchecking <b>Stop on first build error</b> will force the compiler to attempt to build all referenced
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   117
	projects even if the current project has errors.</dd>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   118
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   119
	<dt>Workbench Build Behavior</dt>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   120
	<dd>On the <b>Behaviour </b> tab, this controls which makefile target will be built depending on the scope of the
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   121
	build, e.g. <code>all</code> or <code>clean</code>.</dd>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   122
</dl>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   123
<p>For a standard (non-Makefile) project (often called "Managed Build" or "Managed Make" project from
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   124
earlier CDT version), the project properties dialog enables
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   125
you to manage the build configurations of your project. For additional
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   126
information see:</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   127
<ul>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   128
  <li><b>Reference &gt; C/C++  Properties &gt; C/C++ Project Properties &gt; Managed Make
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   129
Projects</b></li>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   130
  <li><b>Reference &gt; C/C++  Properties &gt; C/C++ Project Properties &gt; Managed Make File
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   131
Properties</b></li>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   132
</ul>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   133
<h2>Viewing build information</h2>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   134
<p>Build-related information is displayed as follows: </p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   135
<ul>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   136
  <li>The <b>Console</b> view displays the output of the make utility.</li>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   137
  <li>The <b>Tasks</b> view displays a list of compiler errors and
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   138
warnings related to your projects. </li>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   139
  <li>For a Standard Make project, build actions display in the <b>Make
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   140
Targets</b> view.</li>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   141
</ul>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   142
<p><img border="0" src="../images/ngconcepts.gif" alt="Related concepts"
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   143
 width="143" height="21">
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   144
<br>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   145
<a href="cdt_c_projects.htm">CDT Projects</a><br>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   146
<a href="cdt_c_proj_file_views.htm">Project file views</a></p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   147
<p><img border="0" src="../images/ngtasks.gif" alt="Related tasks"
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   148
 width="143" height="21">
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   149
<br>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   150
<a href="../tasks/cdt_o_build_task.htm">Building projects</a></p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   151
<p><img border="0" src="../images/ngref.gif" alt="Related reference"
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   152
 width="143" height="21">
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   153
<br>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   154
<a href="../reference/cdt_u_properties.htm">Project Properties</a></p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   155
&nbsp;
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   156
<p><img src="../images/rh03_04.gif" alt="Red Hat Copyright Statement"><br>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   157
<img src="../images/ng00_04a.gif" alt="IBM Copyright Statement">
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   158
</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   159
</body>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   160
</html>