Skip to main content
summaryrefslogtreecommitdiffstats
blob: 31ed4a873f93934e04bf562cd4f772b119bb63d7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html lang="en">
<head>
	<meta http-equiv="Content-Language" content="en-us">
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>How to bring C/C++ source files into Eclipse</title>
	<link rel="stylesheet" type="text/css" href="../help.css">
</head>

<body>

<h1>Importing your C/C++ source files into Eclipse</h1>

<p>Using the CVS Repository Exploring perspective, you can check
out modules or directories into existing projects, or create new
projects. A common scenario that you may encounter when starting to use the CDT, is determining how 
to bring existing C/C++ source files into Eclipse. There are a number of ways to 
do this. The scenarios described below are recommended approaches.</p>

<h2>Creating a project from source files in CVS</h2>

<p>If your existing source tree is managed in CVS, you can use the CVS 
Repository perspective to &quot;Checkout As...&quot; any folder in the repository. 
The first time you &quot;Checkout As...&quot;, the New Project wizard launches and you need to 
create a C or C++ project for the folder. For more information, see
<a href="../tasks/cdt_t_proj_new.htm">Creating a project</a>,
<a href="../tasks/cdt_t_proj_new_with_template.htm">Creating a project via a project template</a> and
<a href="../tasks/cdt_o_proj_files.htm">Working with C/C++ project files</a>.</p>

<p>After you perform a checkout operation, a CVS checkout of the project occurs into the project's location. It is recommended that you eventually add and commit the CDT project files back into CVS.  
These files include .project, .cdtproject, and .cdtbuild (for Managed Build projects) and are located at the root folder of each CDT project.</p>

<p>
Bringing code into the IDE from CVS differs slightly, depending on what
you're importing:
</p>

<ul>
    <li>an existing C/C++ project
    </li>

    <li>existing C/C++ code that isn't part of a project
    </li>

    <li>
    existing C/C++ code that needs to be added to an existing project
    </li>
</ul>

<h3>Importing a C/C++ project from CVS</h3>

<p>
To check out an existing C/C++ project from the CVS repository into your workspace, right-click the project in the CVS Repositories view, and select <b>Check Out</b> from the menu. A project with the same name as the CVS module is checked out in to your workspace. 
</p>


<h3>Importing C/C++ code from CVS</h3>

<p>
To check out existing C/C++ code that is not part of a project:
</p>

<ol>
    <li>
    Right-click the module or directory in the CVS
    Repositories view and choose <b>Check Out As&hellip;</b>
    from the menu.
    
    <p>
    The Check Out As wizard dispalys.
    </p>

     </li>

    <li>
    Choose how to check out this project:

    <ul>
        <li>
        as a project configured using the New Project
        wizard

        <p>
        or:
        </p>
        </li>

        <li>
        as a new project in the workspace

        <p>
        or:
        </p>
        </li>

        <li>
        as a Standard Make C/C++ Project &ndash; if you need to create your own
        Makefile to integrate with an existing build
        process
        </li>
    </ul>

    <p>
    Choose the workspace location for this project, then the CVS
    tag to check out.  
    <li>Click <b>Finish</b> to exit the <b>Check Out As</b> dialog.
    </p>

    <li>Click <ui>Next</ui> to continue.
</ol>

<h3>Importing C/C++ code into an existing project</h3>

<p>
To import a directory full of C/C++ code into an existing project:
</p>

<ol>
    <li>
    Right-click the module or directory in the CVS
    Repositories view and choose <ui>Check Out As&hellip;</ui>
    from the menu.

    <p>
    The IDE displays the Check Out As dialog.
    </p>

<li>Choose <ui>Check out into an existing project</ui>, and then click
  <ui>Next</ui>.
  The IDE displays the Check Out Into dialog:

    <p>
    <img src="images/cvs-checkout-into.gif" alt="Check Out Into">
    </p>
    </li>

    <li>
    Select an existing project from the list, and then
    click <ui>Finish</ui> to add the code from CVS to the selected
    project.
    </li>
</ol>


<h2>Creating new projects from existing source roots</h2>

If your resource code is not managed in CVS but is available from the file system, then you need to perform two steps:
<ol>
	<li>Identify a "root folder" of your source code tree.</li>
	<li>Create a new C/C++ project using the New Project Wizard, and specify the "root folder" as a non-default location of the new project.</li>
</ol>
<p>Typically existing projects will have their own makefiles, so you should create a new Standard Make C/C++ project.  For more information see 
<a href="../tasks/cdt_t_proj_new.htm">Creating a project</a> and
<a href="../tasks/cdt_o_proj_files.htm">Working with C/C++ project files</a>.</p>

<p>To help you to identify a root folder for your project, consider the following guidelines:
<ul>
	<li>all source code for the project is available on or beneath the root folder</li>
	<li>the build results are also produced in or beneath the root folder</li>
	<li>there is often a makefile in the root folder.  In complex projects, the makefile in the root folder calls other makefiles in other directories to produce the build results.</li>
	<li>external header files and library files do not need to be in or beneath the root folder.</li>
</ul></p>

<p>The resources for the project are maintained in the remote location specified, 
not in the workspace folder for Eclipse. However, your existing folder structure 
is displayed in the C/C++ Projects view. Meta data for the project, such as the 
index for the project and the link to the existing source, is stored in the metadata 
directory in the workspace folder. For more information on the workspace folder, 
see <b>Workbench User Guide &gt; Tasks &gt; Upgrading Eclipse</b>.</p>

After you create a CDT project, you cannot easily move it or redefine its root folders.  
If you need to, you can delete the CDT project (without deleting its contents) and then 
recreate it specifying a different non-default location.

<h2>Import your C/C++ source file system</h2>

<p>Another approach would be to create a C/C++ Project and then import your 
existing file system.

For more information about importing, see <b>Workbench User Guide &gt; Tasks &gt; Importing &gt; 
Importing resources from the file system</b>.</p>

<p>This approach copies the files from your file system to an Eclipse Workbench 
project or folder. Your original source files remain unchanged and it is the 
copies of the files that will be edited, built and debugged using the CDT.&nbsp; 
When you have successfully imported your existing file system, the folder 
structure is displayed in the C/C++ Projects view.  Again, you should identify an
appropriate "root folder" to import from.</p>

<p><b>Tip:</b>

<ul>
  <li>Importing your existing file system can consume significant disk space 
  depending on the size of your files.</li>
  <li>Your files may become detached from an existing source control system that 
  previously referenced the original file location such as a ClearCase view.</li>
</ul></p>

<p><img border="0" src="../images/ngconcepts.gif" ALT="Related concepts" width="143" height="21">
<br>
<a href="../concepts/cdt_c_over_cdt.htm">Overview of the CDT</a><br>
&nbsp;<a href="../concepts/cdt_c_projects.htm">CDT Projects</a></p>
<p><img border="0" src="../images/ngtasks.gif" ALT="Related tasks" width="143" height="21">
<br>
<a href="../tasks/cdt_o_proj_files.htm">Working with C/C++ project files</a></p>
<p><img border="0" src="../images/ngref.gif" ALT="Related reference" width="143" height="21">
<br>
<a href="../reference/cdt_o_proj_prop_pages.htm">Project properties</a></p><p>

<img src="../images/ng00_04a.gif" ALT="QNX Copyright Statement" >

</body>

</html>

Back to the top