To use Eclipse for C/C++ programming, you need a C/C++ compiler. On Windows, you could install MinGW. MinGW, stands for "Minimalist GNU for Windows", is a minimalist development environment for native Microsoft Windows applications .MinGW provides a complete Open Source programming tool set which is suitable for the development of native MS-Windows applications, and which do not depend on any 3rd-party C-Runtime DLLs. MinGW is a port of the GNU Compiler Collection (GCC), including C, C++, ADA and Fortran compilers.
Install MinGW GCC
- Goto MinGW site at http://www.mingw.org/ ⇒ Downloads ⇒ Installer ⇒ click on "mingw-get-setup" link to download the installer.
- Run the downloaded installer (mingw-get-setup.exe). By default it gets installed in c:\mingw folder. In case you are changing the folder name use a folder name without spaces.
- Run MinGW Installation Manager, select "Installation" ⇒ "Update Catalogue" ⇒ Select all packages in "Basic Setup" ⇒ continue. Installation ⇒ Update changes.
Alternatively you can install mingw using command line. Go to MINGW\bin folder and type mingw-get install gcc g++
- Setup environment variable PATH to include "<MINGW_HOME>/bin" where <MINGW_HOME> is the MinGW installed directory that you have chosen in the previous step.(Control Panel -> System and security ->System->Advanced system settings - >Environment Variables and Update te path)
- If you did not find make.exe in MingW Folder. Copy mingw32-make.exe file in the same folder and rename the copied file as make.exe.
You can copy the MingW folder to other Systems. Separate installation in each system is not needed.
Install Eclipse C/C++ Development Tool (CDT)
- Download Eclipse IDE for C/C++ Developers from eclipse.org. Unzip the zip file to eclipse folder.
- If you have already installed "Eclipse for Java Developers" or other Eclipse packages, you could install the CDT plug-in as follows:
Launch Eclipse ⇒ Help ⇒ Install New Software ⇒ In "Work with" field, pull down the drop-down menu and select "All Available Sites" Choose Under Programming languages choose C/C++ Development Tools SDK
Writing C/C++ Program in Eclipse
Step 0: Launch Eclipse
- Start Eclipse by running "eclipse.exe" in the Eclipse installed directory.
- Choose an appropriate directory for your workspace (i.e., where you would like to save your works).
- If the "welcome" screen shows up, close it by clicking the "close" button.
Step 1: Create a new C++ Project
- For each C++ application, you need to create a project to keep all the source codes, object files, executable files, and relevant resources.
- To create a new C++ project:
- Choose "File" menu ⇒ "New" ⇒ Project... ⇒ C/C++ ⇒ C++ project.
- The "C++ Project" dialog pops up.
- In "Project name" field, enter "FirstProject".
- In "Project Types" box, select "Executable" ⇒ "Empty Project".
- In "Toolchains" box, choose your compiler,"MinGW GCC" ⇒ Next.
- The "Select Configurations" dialog appears. Select both "Debug" and "Release" ⇒ Finish.
- In the "Project Explorer" (leftmost panel) ⇒ Right-click on "FirstProject" (or use the "File" menu) ⇒ New ⇒ Source File.
- The "New Source File" dialog pops up.
- In "Source file" field, enter "Hello.cpp".
- Click "Finish".
- The source file "Hello.cpp" opens on the editor panel (double-click on "test.cpp" to open if necessary). Enter the following codes:
Our C Programming book contains programs using conio.h and graphics.h. These libraries are for DOS and they are discontinued. Please look this space for new graphics related programs.