Many people complain that configuring Eclipse+CDT/EasyEclipse IDE to work with MinGW C/C++ compiler tools on Windows doesn’t always go on expected lines. I hope the following howto would go some distance in addressing this issue. I use EasyEclipse IDE(what is EasyEclipse?) in this howto but the same procedure applies to Eclipse + CDT combination too.

To set up a C++ development environment using Eclipse+CDT/EasyEclipse and MinGW on a Windows operating system, the following steps need to be completed:

  1. Download and Install MinGW for Windows.
  2. Set MinGW in system PATH.
  3. Download and Install EasyEclipse for C++ and configure it to use MinGW tools.
  • Download and Install MinGW for Windows

    1. First download the Automated MinGW Installer from the sourceforge.net website.

      Download MinGW C/C++ From Sourceforge

    2. From whatever location you run the downloaded MinGW installer, it creates a few settings file there. So I recommend moving it to its own directory before running it. Move the installer file to a location like C:\mingw\ and run it from there.

      You will see a welcome dialog; click Next to continue. Select “Download and Install” option from the next dialog box and click Next.

      Installing MinGW C/C++ on Windows

    3. Read the license and click Next if you agree to it. Select “Current” option from the next dialog box and click Next.

      Installing MinGW C/C++ on Windows

    4. Select at least “g++ compiler” and “MinGW make” from the shown components and click Next.

      Installing MinGW C/C++ on Windows

    5. Accept the default install location or enter a new location(should not contain any spaces in the path name) in “Destination Folder” text box and click Next.

      Installing MinGW C/C++ on Windows

    6. Accept the suggested Start Menu shortcut and click Install to begin the installation procedure. Depending on the number of selected components in Step 4 and the Internet speed, the download may take some time. When the installation is finished, click Close to dismiss the installer. MinGW is now installed on the system.
  • Set MinGW in system PATH

    The second step is to add the MinGW bin directory path to the system/user PATH variable.

    1. Right-click on “My Computer,” go to “Advanced” tab and click the “Environment Variables…” button.

      Setting PATH variable for MinGW C/C++ on Windows

    2. Select the entry of PATH field, click the “Edit” button, hit the END key on the keyboard, add a semicolon and then type/paste the MinGW bin directory path. Click OK to dismiss all the dialog boxes.

      Setting PATH variable for MinGW C/C++ on Windows

    3. To verify that the PATH variable is set correctly, select to Start -> Run command and enter cmd in the text box. In the command window, type:
      C:\> g++ -v

      You should see the version information displayed.

      Checking GCC version of MinGW on Windows

      If you get an error that g++ command is not found, then you have not set the PATH properly. Repeat the above instructions carefully or search through the Internet to learn how to change PATH variable in Windows.

  • Configure EasyEclipse for C++ to use MinGW tools

    The third step is to download EasyEclipse for C++ package for the Windows OS and unpack it to a directory(say, C:\easyeclipse).

    Go to the unpacked directory and click on the startup.jar file to run the EasyEclipse for C++ IDE. (You can right-click on this file and send a shortcut to the desktop or pin it to the start menu or add it to quick launch panel for easier access in the future.)

    1. To create a new C++ project, select File -> New -> Managed Make C++ project(File->New -> New Project to see all the options), enter a name and click Finish.

      Developing C/C++ Applications in EasyEclipse with CDT

    2. Once the project is created, change the default ‘Build Command’ from ‘make -k’ to ‘mingw32-make -k’(to use MinGW’s make tool). This setting can be changed from Project -> Properties -> C/C++ Build -> Build Settings tab:

      Developing C/C++ Applications in EasyEclipse with CDT
      You can also access project settings by right-clicking on the project name and selecting ‘Properties’.

    3. To add a new file to the project, select File -> New -> Source File, enter a name(say, hello.cpp) in the ‘Source File:’ text box and click Finish.

      Type the following program in the editor:
      [cpp]
      #include
      #include

      int main()
      {
      std::string name = “world”;
      std::cout << "Hello, " << name << ".";
      std::cout << std::endl;
      }
      [/cpp]

      As soon as the file is saved, it is built automatically. The errors, if any, are highlighted by underlining them with red lines.

      Developing C/C++ Applications in EasyEclipse with CDT

      If you want to build the project manually, then uncheck the “Build Automatically” option from the Project menu.

      Developing C/C++ Applications in EasyEclipse with CDT

    4. You are all set to add additional source (and header) files to the project now and expand the C++ application. Remember that Step 2 has to be repeated for every new C++ application created.

      Developing C/C++ Applications in EasyEclipse with CDT

Good luck!