C, C++ compiler and editor on Windows – Easy How To

In this tutorial I am going to show you how to get a C/C++ compiler/editor on your computer plus as an added bonus you’ll also get Java and Fortran compilers without any extra effort.

Windows is not a developer platform and is not out of the box ready for programming, especially when it comes to C/C++. So we are going to need to download and configure a few programs.

The first program we need is called Cygwin. Cygwin is a Linux emulator that contains our compilers. The second is called NetBeans. It is an IDE (Integrated Development Environment) that takes the compilers and makes them easy to use with tools like code completion and project management.

Installing Cygwin

  1. Download the Cygwin installer http://www.cygwin.com/ and download the setup.exe file
  2. Run the setup.exe file. Follow the default “next” install sequence until it asks you to select a download site, just pick any download site you feel like. Click next…
  3. The next step is where things get a little more complicated. Cygwin comes with a whole slew of Linux programs. All we really want are the compilers.
    • As shown circled in red in the picture below type “gcc”
    • Click the “Devel” tab plus mark
    • Click on the black ‘s’ looking thing to install a package. This should make the package say install.
    • Click on each of the packages I have outlines in red along with any other packages/compilers you feel like.
    Cygwin Package Manger

    Select the Compilers You Need

    • We need to do the same thing for “make” as we did for “gcc” following the same process. The picture below show you which package to get.
    Cygwin Package Manager

    Get the Make Package

    After selecting your packages click “Next.” Go watch a few youtube clips while it installs the packages and finish the installation.

Installing Netbeans

Netbeans is usually know as a Java IDE. However it has support for C/C++ and because you have installed Cygwin you could create c/c++ programs.

Netbeans needs the Java SDK to run. Get the JDK here (or google Java JDK download) and install it.

Download NetBeans http://netbeans.org/downloads/index.html. Be sure to get the C/C++ version or the “all” version. Install NetBeans.

Getting Netbeans and Cygwin to Play together

Now that you have installed NetBeans start it up. Go to tools -> options and click on the C/C++ tab. After a few seconds of loading you should see a screen similar to the picture below.

If You See this Screen You’re Golden. Make sure you have the C Compiler, C++ Compiler and make commend.

If you see this screen that means you should be able to make and compile c/c++, Java, Fortran, and even assembly programs. Congratulations! Everything worked!

C/C++ Hello World!

Now that you have it “working” you probably want to get started. For the rest I will guide you through a basic hello world program.

  1. Go to File -> New Project
  2. Select C/C++ and select C/C++ application under projects and click “Next”
  3. Give the project a name and click “Finish”
  4. Some folders should appear on the left hand side. Click on the source files tab and double click on “main.cpp”
  5. See the picture below and enter the changed code to print “Hello World!”
  6. Click Run -> Run Main Project
  7. Congratulations!!! You now have a working compiler and a working first program… hopefully.You should see your programs output at the bottom of the IDE.

  8. If you have any questions or problems comment below.
This entry was posted in Uncategorized. Bookmark the permalink.