|
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> |
|
2 <html lang="en"> |
|
3 <head> |
|
4 <meta http-equiv="Content-Language" content="en-us"> |
|
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
|
6 <title>How to bring C/C++ source files into Eclipse</title> |
|
7 <link rel="stylesheet" type="text/css" href="../help.css"> |
|
8 </head> |
|
9 |
|
10 <body> |
|
11 |
|
12 <h1>Importing your C/C++ source files into Eclipse</h1> |
|
13 |
|
14 <p>Using the CVS Repository Exploring perspective, you can check |
|
15 out modules or directories into existing projects, or create new |
|
16 projects. A common scenario that you may encounter when starting to use the CDT, is determining how |
|
17 to bring existing C/C++ source files into Eclipse. There are a number of ways to |
|
18 do this. The scenarios described below are recommended approaches.</p> |
|
19 |
|
20 <h2>Creating a project from source files in CVS</h2> |
|
21 |
|
22 <p>If your existing source tree is managed in CVS, you can use the CVS |
|
23 Repository perspective to "Checkout As..." any folder in the repository. |
|
24 The first time you "Checkout As...", the New Project wizard launches and you need to |
|
25 create a C or C++ project for the folder. For more information, see |
|
26 <a href="../tasks/cdt_t_proj_new.htm">Creating a project</a>, |
|
27 <a href="../tasks/cdt_t_proj_new_with_template.htm">Creating a project via a project template</a> and |
|
28 <a href="../tasks/cdt_o_proj_files.htm">Working with C/C++ project files</a>.</p> |
|
29 |
|
30 <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. |
|
31 These files include .project, .cdtproject, and .cdtbuild (for Managed Build projects) and are located at the root folder of each CDT project.</p> |
|
32 |
|
33 <p> |
|
34 Bringing code into the IDE from CVS differs slightly, depending on what |
|
35 you're importing: |
|
36 </p> |
|
37 |
|
38 <ul> |
|
39 <li>an existing C/C++ project |
|
40 </li> |
|
41 |
|
42 <li>existing C/C++ code that isn't part of a project |
|
43 </li> |
|
44 |
|
45 <li> |
|
46 existing C/C++ code that needs to be added to an existing project |
|
47 </li> |
|
48 </ul> |
|
49 |
|
50 <h3>Importing a C/C++ project from CVS</h3> |
|
51 |
|
52 <p> |
|
53 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. |
|
54 </p> |
|
55 |
|
56 |
|
57 <h3>Importing C/C++ code from CVS</h3> |
|
58 |
|
59 <p> |
|
60 To check out existing C/C++ code that is not part of a project: |
|
61 </p> |
|
62 |
|
63 <ol> |
|
64 <li> |
|
65 Right-click the module or directory in the CVS |
|
66 Repositories view and choose <b>Check Out As…</b> |
|
67 from the menu. |
|
68 |
|
69 <p> |
|
70 The Check Out As wizard dispalys. |
|
71 </p> |
|
72 |
|
73 </li> |
|
74 |
|
75 <li> |
|
76 Choose how to check out this project: |
|
77 |
|
78 <ul> |
|
79 <li> |
|
80 as a project configured using the New Project |
|
81 wizard |
|
82 |
|
83 <p> |
|
84 or: |
|
85 </p> |
|
86 </li> |
|
87 |
|
88 <li> |
|
89 as a new project in the workspace |
|
90 |
|
91 <p> |
|
92 or: |
|
93 </p> |
|
94 </li> |
|
95 |
|
96 <li> |
|
97 as a Standard Make C/C++ Project – if you need to create your own |
|
98 Makefile to integrate with an existing build |
|
99 process |
|
100 </li> |
|
101 </ul> |
|
102 |
|
103 <p> |
|
104 Choose the workspace location for this project, then the CVS |
|
105 tag to check out. |
|
106 <li>Click <b>Finish</b> to exit the <b>Check Out As</b> dialog. |
|
107 </p> |
|
108 |
|
109 <li>Click <b>Next</b> to continue. |
|
110 </ol> |
|
111 |
|
112 <h3>Importing C/C++ code into an existing project</h3> |
|
113 |
|
114 <p> |
|
115 To import a directory full of C/C++ code into an existing project: |
|
116 </p> |
|
117 |
|
118 <ol> |
|
119 <li> |
|
120 Right-click the module or directory in the CVS |
|
121 Repositories view and choose <b>Check Out As</b> |
|
122 from the menu. |
|
123 |
|
124 <p> |
|
125 The IDE displays the Check Out As dialog. |
|
126 </p> |
|
127 |
|
128 <li>Choose <b>Check out into an existing project</b>, and then click |
|
129 <b>Next</b>. |
|
130 The IDE displays the Check Out Into dialog: |
|
131 |
|
132 </li> |
|
133 |
|
134 <li> |
|
135 Select an existing project from the list, and then |
|
136 click <b>Finish</b> to add the code from CVS to the selected |
|
137 project. |
|
138 </li> |
|
139 </ol> |
|
140 |
|
141 |
|
142 <h2>Creating new projects from existing source roots</h2> |
|
143 |
|
144 If your resource code is not managed in CVS but is available from the file system, then you need to perform two steps: |
|
145 <ol> |
|
146 <li>Identify a "root folder" of your source code tree.</li> |
|
147 <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> |
|
148 </ol> |
|
149 <p>Typically, existing projects will have their own makefiles, so you should create a new Make C/C++ project. For more information see |
|
150 <a href="../tasks/cdt_t_proj_new.htm">Creating a project</a> and |
|
151 <a href="../tasks/cdt_o_proj_files.htm">Working with C/C++ project files</a>.</p> |
|
152 |
|
153 <p>To help you to identify a root folder for your project, consider the following guidelines: |
|
154 <ul> |
|
155 <li>all source code for the project is available on or beneath the root folder</li> |
|
156 <li>the build results are also produced in or beneath the root folder</li> |
|
157 <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> |
|
158 <li>external header files and library files do not need to be in or beneath the root folder.</li> |
|
159 </ul></p> |
|
160 |
|
161 <p>The resources for the project are maintained in the remote location specified, |
|
162 not in the workspace folder for Eclipse. However, your existing folder structure |
|
163 is displayed in the C/C++ Projects view. Meta data for the project, such as the |
|
164 index for the project and the link to the existing source, is stored in the metadata |
|
165 directory in the workspace folder. For more information on the workspace folder, |
|
166 see <b>Workbench User Guide > Tasks > Upgrading Eclipse</b>.</p> |
|
167 |
|
168 After you create a CDT project, you cannot easily move it or redefine its root folders. |
|
169 If you need to, you can delete the CDT project (without deleting its contents) and then |
|
170 recreate it specifying a different non-default location. |
|
171 |
|
172 <h2>Import your C/C++ source file system</h2> |
|
173 |
|
174 <p>Another approach would be to create a C/C++ Project and then import your |
|
175 existing file system. |
|
176 |
|
177 For more information about importing, see <b>Workbench User Guide > Tasks > Importing > |
|
178 Importing resources from the file system</b>.</p> |
|
179 |
|
180 <p>This approach copies the files from your file system to an Eclipse Workbench |
|
181 project or folder. Your original source files remain unchanged and it is the |
|
182 copies of the files that will be edited, built and debugged using the CDT. |
|
183 When you have successfully imported your existing file system, the folder |
|
184 structure is displayed in the C/C++ Projects view. Again, you should identify an |
|
185 appropriate "root folder" to import from.</p> |
|
186 |
|
187 <p><b>Tip:</b> |
|
188 |
|
189 <ul> |
|
190 <li>Importing your existing file system can consume significant disk space |
|
191 depending on the size of your files.</li> |
|
192 <li>Your files may become detached from an existing source control system that |
|
193 previously referenced the original file location such as a ClearCase view.</li> |
|
194 </ul></p> |
|
195 |
|
196 <p><img border="0" src="../images/ngconcepts.gif" ALT="Related concepts" width="143" height="21"> |
|
197 <br> |
|
198 <a href="../concepts/cdt_c_over_cdt.htm">Overview of the CDT</a><br> |
|
199 <a href="../concepts/cdt_c_projects.htm">CDT Projects</a></p> |
|
200 <p><img border="0" src="../images/ngtasks.gif" ALT="Related tasks" width="143" height="21"> |
|
201 <br> |
|
202 <a href="../tasks/cdt_o_proj_files.htm">Working with C/C++ project files</a></p> |
|
203 <p><img border="0" src="../images/ngref.gif" ALT="Related reference" width="143" height="21"> |
|
204 <br> |
|
205 <a href="../reference/cdt_o_proj_prop_pages.htm">Project properties</a></p><p> |
|
206 |
|
207 <img src="../images/ng00_04a.gif" ALT="QNX Copyright Statement" > |
|
208 |
|
209 </body> |
|
210 |
|
211 </html> |