Installing gcc/g++ using MinGW and NetBeans in Windows

C and C++ languages are everywhere. All operating systems use them. People usually choose them because of their limitless power, velocity of execution, great portability and much more. In this tutorial I will show you how to install a C/C++ development environment under Windows. By the way, MinGW includes other compilers for languages like c, c++, objective c fortran and ada.

 

Install MinGW

  • Start the installation.
  • Under Repository Catalogues, select Download latest repository catalogues. You can also keep the Use pre-packaged repository catalogues if your package includes a recent snapshot.

  • Select your installation path. Try to select one that is easily accesible from the command line.
    Note: I have changed my default installation directory to C:optMinGW. This is completely optional.

  • Select C, C++ and other languages you want to install, plus the MSYS Basic System. MSYS includes several handy shell tools like bash, make and grep that will allow you to build applications that depend on UNIX tools to be present.

  • Continue through the wizard screens and press Install.
  • If you chose the option to download the latest repositories, it will take a little bit more.

  • In order to access your compilers from any directory in your system you now have to add the following directories to your PATH environment variable:

 

C:optMinGWbin
C:optMinGWmsys1.0bin

 

Install Netbeans

  • Go to the Netbeans website and select Download
  • Choose an option that includes C/C++

  • Install it
  • Now that Netbeans is installed, we need to configure it to use MinGW. You can do that by going to Tools > Options and selecting the C/C++ tab. If your environment variables are correctly set, Netbeans will find your MinGW installation and will configure itself. The following screen shows how it looks:

Press Ok to accept the changes.
Everything is ready. It is time to test it.

 

Testing the Environment

In Netbeans:

Go to File > New Project. Under Categories select C/C++ and then, under Projects, select C/C++ Application.

Select a project name and folder locations. In my case I’m going to name it CppTest. Press Finish.

After this you should have a project with two files in it. Double click main.cpp to edit it.

What would be a tutorial without a HelloWorld program… Well, type the following program in your editor and press the Execute button (the one that looks like a Play button). If everything goes fine, you should see at the bottom a message greeting the world.

That is it. Now go ahead and create some amazing code.

11 Replies to “Installing gcc/g++ using MinGW and NetBeans in Windows”

  1. Pingback: iOs
  2. i m gettng error while execution.
    CLEAN FAILED (exit value 1, total time: 157ms)
    wat shud i do for dis ? plz reply as soon as possible

  3. the whole thing is

    AllocationBase 0x0, BaseAddress 0x715B0000, RegionSize 0x150000, State 0x10000
    C:msys1.0binmake.exe: *** Couldn’t reserve space for cygwin’s heap, Win32 error 487

    BUILD FAILED (exit value 1, total time: 109ms)

  4. Could you possibly post screen shots of the make files for “Qmake” and “Cmake”? You have a screenshot above for some of the build tools set up but not all. I seem to be having library and directory issues and there is no help on Netbeans or MinGW.

    Also do you know what a “stackdump” file is or why Netbeans and MinGW would be creating a trace to a stackdump file instead of running the program I just created?

Leave a Reply