Every Flavour Beans

“The time has come…to talk of many [technologies].” –Lewis Carroll(’The Walrus and the Carpenter’)
Development Tools. Web Frameworks. GNU/Linux. Nokia N800. Video Encoding.

August 25, 2007

Setting Up C++ Development Environment on Windows with EasyEclipse and MinGW

Filed under: Eclipse/C++ — tabrez @ 11:19 pm

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:

      C++:
      1. #include<iostream>
      2. #include<string>
      3.  
      4. int main()
      5. {
      6.     std::string name = "world";
      7.     std::cout <<"Hello, " <<name <<".";
      8.     std::cout <<std::endl;
      9. }

      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!


If you want to receive future posts by email, enter your email address here:

Related Posts:

  • C++ Development Environment on Windows using Eclipse Ganymede and Nuwen MinGW
  • Wascana is Eclipse Based Standalone C++ IDE for MS Windows
  • EasyEclipse is the Best Packaged Distribution of Eclipse Platform
  • Build C++ Programs With SCons in Eclipse Using SConsBuilder Plugin(MS Windows)
  • Six Popular IDEs For Developing Software in C/C++ on Windows Platform
  • Unit Testing C++ Programs using CppUnit in Eclipse IDE on Windows
  • Creating “Hello World” Web Application Using the Grails Framework

  • 12 Comments »

    1. This is one area that I am trying to address with the open source Wascana project on SourceForge, http://wascana.sourceforge.net. It will also install a few open source libraries that can get you started building Windows apps. We're still a few months away from a 1.0 release, but if you'd like to follow along or give one of the early releases a spin, feel free.

      Quote

      Comment by Doug Schaefer — August 26, 2007 @ 8:07 am

    2. Hi Doug,

      When I first posted a list of six good C++ development environments I did not know of an Eclipse based package that included everything needed for C++ development. But this time around I discovered your project then called CDT for Windows(now Wascana), and I am sure that it will fill the void of a good, standalone, Free C++ IDE on (at least) Windows platform. I have a draft post saved on Wascana(using 0.9.2 version) and will post it in a few days.

      You are doing a great job by packaging everything needed for C++ development as one application and I hope that, given time, it will be found on most of the C++ developers' desktops.

      Quote

      Comment by tabrez — August 26, 2007 @ 12:35 pm

    3. Doug, Tabrez:
      what about joining forces to make it happen together?

      Quote

      Comment by Philippe — August 27, 2007 @ 11:23 am

    4. tabrez on August 28, 2007 at 3:50 pm said:

      Philippe on August 27, 2007 at 11:23 am said:

      Doug, Tabrez:
      what about joining forces to make it happen together?

      I would love to see that happening.

      When I first found out about EasyEclipse, I wondered if the need for integrating MinGW/MSys in its C++ distribution will be felt by someone. Wascana seems such a product. But it uses Eclipse as the starting point whereas I would love to see it use EasyEclipse instead, as EasyEclipse has many C++ related plugins that are already tested thoroughly, like AnyEdit, Subclipse etc. and not just CDT. They may add many more in the future and Wascana can just feed on it. And EasyEclipse on Wascana's MinGW integration even as MinGW keeps releasing newer versions.

      I would really like to see {EasyEclipse + Wascana} provide as rich (and easy to install) development environment for C++ developers as there is for any other technology. Going by Doug's comment on easyeclipse.org and Philippe's comment here, I have a positive feeling about such a collaboration.

      Quote

      Comment by tabrez — August 28, 2007 @ 3:50 pm

    5. I had seriously considered working with EasyEclipse. I am a big fan of Phillipe's work and he is a great ambassador for the Eclipse community.

      However, Wascana is more than just an easy way to get eclipse. My real objective is to build up a community focused on providing a top class open source desktop development solution. Essentially a competator to Visual C++ but as a common environment for Linux and Mac as well, i.e. all the same libraries and required tool chains and plug-ins. Adding new plug-ins to the solution is pretty trivial relative to building libraries and such. But I'd like to focus on the whole developer experience from end-to-end. And that is going to take a while to understand.

      So while I hate to be competing with Phillipe's great effort, I think we have slightly different objectives and focus.

      Quote

      Comment by Doug Schaefer — August 28, 2007 @ 9:05 pm

    6. I wish good luck to both of you in that case to realise your individual objectives.

      Quote

      Comment by tabrez — August 30, 2007 @ 4:00 pm

    7. [...] Wascana Desktop Developer is a completely standalone, Eclipse-based C++ development environment for the Windows platform which packages everything that is needed for developing applications using the C++ language. Download the installer, go through the installation wizard and you have a complete C++ IDE ready to go; unlike EasyEclipse for C++, no additional software or any further configuration is needed. It is based on the popular Eclipse platform and uses the CDT plugin and the MinGW compiler tools to provide the necessary functionality. Called CDT for Windows earlier, it is now renamed to Wascana Desktop Developer to avoid any trademark issues. The latest version, Wascana 0.9.3, was released a few days ago and it comes with the following components integrated into it: [...]

      Quote

      Pingback by Wascana is Eclipse Based Standalone C++ IDE for MS Windows — September 14, 2007 @ 5:22 pm

    8. [...] If the MinGW toolchain is not already installed on your Windows system, download and install MinGW, MSYS and gdb debugger from MinGW’s download page. Similarly download and install the latest version of Eclipse for C++(Europa) if it’s not already installed. If you are willing to take my recommendation, I suggest you start with EasyEclipse for C++ IDE which comes with many useful C++ plugins pre-installed. When you install EasyEclipse/Eclipse Europa for C++, it will automatically detect the MinGW installation and will configure all paths properly, but if for some reason you come across any problem(or if you are using an older version of Eclipse), take a look at my earlier post on how to configure MinGW with Eclipse IDE. [...]

      Quote

      Pingback by Build C++ Programs With SCons in Eclipse Using SConsBuilder Plugin(MS Windows) — October 24, 2007 @ 9:13 pm

    9. [...] C++ toolchain must already be installed and configured with your Eclipse IDE; if not, read the MinGW and EasyEclipse configuration post for more information; it’s for older version of the Eclipse and configuration is much simpler [...]

      Quote

      Pingback by Unit Testing C++ Programs using CppUnit in Eclipse IDE on Windows — November 26, 2007 @ 10:47 pm

    10. After numerous searches and guides, you were the first to actually be able to clearly show what I was doing wrong when trying to set up the mingw environment on winXP... Thank you so much.

      Quote

      Comment by Leonardo Sileniek — July 18, 2008 @ 11:48 pm

    11. Glad that it helped Sileniek. Try the new Eclipse Ganymede for C++ and let me know how you like it.

      Quote

      Comment by tabrez — July 24, 2008 @ 5:32 pm

    12. [...] this post to be an update of my previous post “Setting Up C++ Development Environment on Windows with EasyEclipse and MinGW.” I will be using the following components in this post to setup the development environment [...]

      Quote

      Pingback by C++ Development Environment on Windows using Eclipse Ganymede and Nuwen MinGW — August 6, 2008 @ 9:37 pm

    RSS feed for comments on this post. TrackBack URI

    Leave a comment

    Subscribe without commenting


    Copyright (c) 2006, 2007 Tabrez Iqbal.
    Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. Verbatim copying and distribution of this entire article is permitted in any medium without royalty provided this notice is preserved. A copy of the license is included in the section entitled "GNU Free Documentation License".


    Powered by WordPress
    This website is hosted by Dreamhost