How to write and compile your first c++ program in eclipse under windows os?

I am a beginner in c++ programming language and I am about to write my first piece of c++ program today after a few days of learning that language but before I start to write c++ script and run it I will certainly need to find a code editor to write the code and a compiler to compile the script. Below are what I have to do before I can start writing program in c++…

Install C++ IDE : Basically we can use any IDE we wish to write our c++ program, we can also write c++ program without any IDE and then compile and run it under the windows command prompt but I do prefer to use Eclipse to write and compile the program instead. Here is the link to download an eclipse which special builds for the c++ development. This eclipse has the basic C/C++ Development Tools that a developer needs to develop his or her c/c++ program which includes the tool to automatically searches for the c++ compiler which we will need to compile and run the c++ program.

Install GCC compiler : We also need the c++ compiler to compile and run the program. We can either go to MinGW website to download the installer to install the c++ compiler or download the gcc compiler through this direct alternative link if we have troubled downloading the compiler through MinGW installer.

After we have those two elements ready just open up our new eclipse and create a new c++ project through File->New->C++ Project, give your project a name, at this moment you should see the MinGW compiler listed under ToolChains, select it, also select the Hello World C++ Project template under Project type which we can then edit it later on, next click Finish to create the new project.

c++ project
c++ project

Open up the HelloWorld.cpp file under the src folder of the project and go to Project->Build Project. Now we can simply run the program by clicking on the green button at the tool bar.

Build and Run the project
Build and Run the project

That is it, I have created my first c++ program and I hope you will do the same too!

Like this post? Kindly share!