How to write and compile a C++ program in Windows using an IDE

In this tutorial I’ll show you how to write and compile a C++ Program using CodeBlocks in Windows. That’s right, Windows.

If you haven’t done so, download and install CodeBlocks

Using CodeBlocks to program Hello World

1. Open up CodeBlocks and simply click on “Create a new project”.


Codeblocks




2. In the following window choose Console Application.


Codeblocks Console




3. The next window welcomes you to the application wizard. I’d simply check Skip this Page Next Time and click on Next.


Application Wizard




4. Choose C++ project.



C++




5. Type in the appropriate values I have in the following image. If you want, you can change the name of the directory where your project will be saved.

Project




6. For now, simply type in Finish in the next window. No need to change anything.





7. In the Management Tab, Expand Sources, and double click on main.cpp . Unfortunately Hello World is already written for us!





8. Now go to Build -> Build and Run. OR You can simply hit F9 which is the shortcut to build and run your program.




9. Congratulations! You are done!

Useful Resources

C++ Tutorial – Page where our C++ tutorials can be found at.
Hello World – Step by Step telling you what each line of Hello World actually does!



Tags: , , , ,

  • Andy

    Quick tip.

    At the top of this tutorial you tell the reader to download code blocks if they don’t have it. If someone has never used code blocks maybe they don’t know how to set it up. It would be really useful if you had a link to a tutorial that teach the user how to set up code blocks.The edit might look something like this:

    In this tutorial … That’s right, Windows.

    If you haven’t done so, download and install CodeBlocks. If you are not familiar with code blocks click here for a quick guide on how to set it up.

    Just a suggestion… :)

  • Andy

    Quick tip.

    At the top of this tutorial you tell the reader to download code blocks if they don’t have it. If someone has never used code blocks maybe they don’t know how to set it up. It would be really useful if you had a link to a tutorial that teach the user how to set up code blocks.The edit might look something like this:

    In this tutorial … That’s right, Windows.

    If you haven’t done so, download and install CodeBlocks. If you are not familiar with code blocks click here for a quick guide on how to set it up.

    Just a suggestion… :)

  • Diego

    If they download the one with the compiler then they should be fine.

  • sard

    Thanks, this was very useful.

  • sard

    Thanks, this was very useful.

  • CKKwok

    Sorry!

    I try for about an hour but only get
    “test1 – Release” uses an invalid compiler. Skipping…
    Nothing to be done.

    I am not good in computer. Would you mind to give me some help?

    I use Windows XP

  • CKKwok

    Sorry!

    I try for about an hour but only get
    “test1 – Release” uses an invalid compiler. Skipping…
    Nothing to be done.

    I am not good in computer. Would you mind to give me some help?

    I use Windows XP

  • Diego

    Did you download CodeBlocks with MinGW? (The compiler) ?

  • jon

    I was able to download and install codeblocks with MinGW, and was able to see the “Hello World!” program, but same with CKKwok, I got a “7 – Debug” uses an invalid compiler… Skipping…

    Anyone who can help?

  • jon

    I was able to download and install codeblocks with MinGW, and was able to see the “Hello World!” program, but same with CKKwok, I got a “7 – Debug” uses an invalid compiler… Skipping…

    Anyone who can help?