How to bring C/C++ source files into Eclipse

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.

Create new projects for existing source roots

If you can access the source from your desktop using the command line, then you can make the root source folders Eclipse projects. This is accomplished by creating a C/C++ Standard Make Project. For more information, see Creating a project and Defining project properties.

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 Workbench User Guide > Tasks > Importing > Upgrading Eclipse.

Create a project from CVS

If your existing source tree is managed in CVS, you can use the CVS Repository perspective to "Checkout As..." any folder in the repository. The first time you "Checkout As...", the New Project wizard is launched and you need to create a C or C++ project for the folder. For more information, see Creating a project and Defining project properties.

A CVS checkout of the project into the project's location occurs.

Import your C/C++ source file system

Another approach would be to create a C/C++ Project and then import your existing file system. For more information, see Workbench User Guide > Tasks > Importing > Importing resources from the file system.

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.  When you have successfully imported your existing file system, the folder structure is displayed in the C/C++ Projects view.

Tip:

Related concepts
Overview of the CDT
 CDT Projects

Related tasks
Working with C/C++ project files

Related reference
Project properties

Copyright IBM Corporation
 2000, 2002. All Rights Reserved.