## Setting up Eclipse CDT IDE

## Guoxian Zhou 04/10/2008

Eclipse is free software available for Windows as well as Linux. C/C++
applications developed in Eclipse can be easily taken to any other
platforms very easily. Also as a developer, if you are familiar with
Eclipse development environment, switching from Windows to Linux is
easy. This instruction will show how to install the CDT plug-in to
Eclipse and configure the development environment.

Steps

1.  Download and install java runtime environment (Java 5 JRE or later
    version recommended). You can find it:
    <http://java.sun.com/javase/downloads/index.jsp>.

    1.  Download the exe file, and follow the steps to install the JDK
        and JRE. The default path should be like C:\\Program
        Files\\Java\\jre1.6.0_04.

    2.  Setup the path: for windows, start -\> right click My Computer
        -\> properties -\> advanced -\> Environment Variables -\>Edit
        the System Path and add the JDK directory to the path. For
        Linux, add the JDK directory to your path.

    3.  Test your environment by type: java \--version and javac
        \--version, you will see the java version you installed. (For
        windows, you need open Command Prompt from All programs -\>
        accessories)

2.  Download and extract the latest Eclipse version (currently 3.3.2) to
    a suitable directory. You can find this in Eclipse website:
    <http://download.eclipse.org/eclipse/downloads/>. Download and unzip
    the driver with pathnames to a folder or directory of your choice
    such as D:\\eclipse.

3.  Launch Eclipse. It will launch without any problems if you have Java
    runtime environment installed. If you get error message like "A Java
    Runtime Environment (JRE) or Java Development Kit (JDK) must be
    available in order to run Eclipse..." when you start Eclipse, it
    means Eclipse can't find a JRE/JDK to use. When you see this
    message, return to step 1 to install JRE/JDK and setup the path.
    Following the below steps to add the CDT plug-in.

![](media/image1.png){width="4.5625in" height="2.5416666666666665in"}

1.  Select a workspace directory by clicking "Browse..." (Such as
    D:\\workspace), and click "ok". The CDT plug-in will be installed to
    .metadata/.plugins subdirectory under your workspace. You should use
    the same workspace to install all your plug-ins and start Eclipse
    with the same workspace so that Eclipse can find all your plug-ins.

> ![](media/image2.png){width="3.7715277777777776in"
> height="2.3958333333333335in"}

2.  Go to Help -\> Software Updates -\> Find and Install...

![](media/image3.png){width="4.25in" height="3.9590277777777776in"}

3.  Select "Search for new features to install", and click "next"

![](media/image4.png){width="4.475in" height="4.16875in"}

4.  Select "New Remote Site..."

![](media/image5.png){width="3.7083333333333335in"
height="1.6041666666666667in"}

5.  Input Name as "CDT", URL as
    <http://download.eclipse.org/tools/cdt/releases/europa>", click
    "ok". The CDT is very tied to specific versions of the Eclipse
    Platform release, so pick up the corresponding version based on the
    instruction from the website.

![](media/image6.png){width="4.625in" height="4.308333333333334in"}

6.  Click "finish". Now Eclipse will [connect to the
    Internet](http://www.codeproject.com/KB/tips/CPP_Dev_eclipse_CDT.aspx)
    location specified and install the required components for Eclipse
    CDT.

![](media/image7.png){width="4.749305555555556in"
height="3.9715277777777778in"}

7.  Select "Install All"

![](media/image8.png){width="4.593055555555556in"
height="1.5104166666666667in"}

8.  Click "yes" to restart Eclipse.

**Congratulations! You have installed the CDT plug-in for your
Eclipse.**

4.  Tutorial -- How to create C sample project.

![](media/image9.png){width="3.4715277777777778in"
height="3.6243055555555554in"}

1.  Select File -\> New -\> Project...

![](media/image10.png){width="4.116666666666666in"
height="4.124305555555556in"}

2.  Select C Project under C folder, and then click "Next".

![](media/image11.png){width="5.291666666666667in" height="5.9375in"}

3.  Provide project name such as "HelloWorld", then Next.

> ![](media/image12.png){width="5.291666666666667in" height="5.9375in"}

4.  Provide basic project properties, then Next.

![](media/image13.png){width="4.221527777777778in"
height="3.660416666666667in"}

5.  Click "Next", then "Finish" to build the C project development.

![](media/image14.png){width="5.0in" height="3.988888888888889in"}

6.  Now you get the perspective of the C project.

> ![](media/image15.png){width="2.2291666666666665in"
> height="2.9784722222222224in"}

7.  Select your HelloWorld project from Project Explorer, then select
    Project -\> Build Project

![](media/image16.png){width="5.371527777777778in"
height="1.4381944444444446in"}

8.  Build successfully. If you get an error message like this \"**error
    launching external scanner info generator /GCC -E -P -v -dD eclipse
    CDT**\", you do not install GCC tool, or the GCC compiler required
    for compiling the source files are not present in the path. You
    confirm this by typing \"**gcc \--version**\" in command prompt. If
    you get a message saying command not found, you can be sure that GCC
    compiler is not available.

> ![](media/image17.png){width="2.5631944444444446in"
> height="4.259722222222222in"}

9.  Select your HelloWorld project from Project Explorer, and then
    select Run -\> Run.

> ![](media/image18.png){width="3.9902777777777776in"
> height="0.9895833333333334in"}
>
> The program prints out "Hello World". Now you have finished your first
> C program under Eclipse CDT environment!
>
> For running CDT from Eclipse, you need to have the following tools.

-   Make tools for make process.

-   GNU compiler collection (GCC) for compilations.

-   GDB for debugging.

> You can download all these tools from
> [www.MinGW.org](http://www.mingw.org/). You have to download and
> install build tools (make), compiler (GCC) and debugger (GDB). You can
> find all these tools in the location
> [www.cygwin.com](http://www.cygwin.com/) also.

4.  How to configure the development environment

> ![](media/image19.png){width="3.8222222222222224in"
> height="7.990972222222222in"}

1.  Right click your project, and then select "Properties"

> ![](media/image20.png){width="5.992361111111111in"
> height="4.800694444444445in"}

2.  Select C/C++ Build to configure the builder settings. You can use
    default make tool, or gmake tool to build your project. AWIPS
    developers can also use dc_compile and dc_fastmake commands here
    (need setup the environment before launching Eclipse).

> ![](media/image21.png){width="2.5729166666666665in"
> height="4.280555555555556in"}

3.  Select \"**Run-\>Open Run Dialog...\"** and configure the run/debug
    environment.

> ![](media/image22.png){width="5.99375in" height="6.065972222222222in"}

4.  Select your project from the "C/C++ Local Application" to edit. Or,
    if your project is not in the list, you can right click "C/C++ Local
    Application"  "New" to create a new one for your project.

> ![](media/image23.png){width="3.3958333333333335in"
> height="2.997916666666667in"}

5.  From the "Main" dialog, set Project by click "Browse" and select the
    project from the list that you want to configure.

> ![](media/image24.png){width="5.997222222222222in"
> height="3.8402777777777777in"}

6.  From the "Main" dialog, set C/C++ Application by click "Browse" and
    navigate to the executable file of project.

> ![](media/image25.png){width="5.99375in" height="6.065972222222222in"}

7.  From the "Arguments" dialog, set parameter(s) for running/debugging
    your project. All these parameters will follow your executable file
    when you run/debug your project.

![](media/image26.png){width="5.99375in" height="6.065972222222222in"}

8.  From the "Debugger" dialog, set debug parameter(s) for debugging
    your project. Then click "Apply".

> Now your basic run/debug environment has been configured. You can run
> and debug your project in Eclipse. You need setup your environment
> before you launch Eclipse if your project needs some specific
> parameters.