C++ Environment Setup

September 13, 2015 Posted by WithU Technologies
There are various ways or modes to develop C++ programs. They have their own advantages and disadvantages. We select four ways to develop C++ programs and arrange them below as four different options to setup C++ IDE for Windows, Linux and MAC OS as well.

The C++ programs will be written inside .cpp files, the source files are extend with .cpp extensions.

Option I – (Recommended and used throughout the session)

(Both for Linux and Windows)

Installation:

GNU Compiler Installation:



  • Run GNU Compiler and change its installation path to C:\MinGW and then complete the installation.

Eclipse Installation:

  • Now Extract the Eclipse Zip file and then copy that extracted file.


  • Then paste it according to your Windows version as shown:

    Windows 64 bit- C:\Program Files

    Windows 34 bit- C:\Program Files (x86)

  • Then Open that Eclipse folder and right click on eclipse.exe application file to make a desktop shortcut or pin that to taskbar.

  • Open Eclipse from that shortcut. Now Click on Workbench from the Top left corner. After it opened completely it will looked something like this:



  • After that from the Menu toolbar. Click on Window and then Preferences. Toggle General from the left sidebar.

  • Click on Workspace and you notice down here at the bottom of the text filling coding.

Note: This is very important. Our files are cross-platform and they are in the UTF-8. So, that is not the default for Windows. This just work fine at least most of the time but UTF-8 is now the standard and so if you are working with source files then they are going to share with anybody else that might be working on different OS.

  • Select Other under the Text file encoding and change it to UTF-8 and under Next text file line delimiter select Other and change it to UNIX.



  • After that click on Apply.

  • Comeback to sidebar and toggle C/C++ triangle arrow, and then click on New C/C++ Project Wizard.

  • Then on the new pop up window select Empty Project.

  • Uncheck Show project types and toolchains only if they are supported on the platform.

  • Select MinGW from toolchains and click on Make toolchain(s) preferred.



  • Click on Apply.

  • Now from General tab toggle triangle arrow of Editors and select Text Editors.



  •  Check ever box except insert spaces for tabs and show print margin and leave everything as it is.

  • Again go to C/C++ and toggle the triangle arrow besides Editor Option there. After that Select Folding.



  • Check and Uncheck the boxes as shown above.

  • Click Ok. That's all for Preferences.

  • Now test the IDE with a pre written Hello World app. Click on File -> New -> C++ Project.

  • Select Hello World C++ Project from Project type and make sure that MinGW GCC is selected in toolchains. Give a Name to your project and then click on Ok.

  • The Hello world project codes will appeared in front of you.

  • Now from Project click on Build All (Ctrl + B). It will build the project.

  • Now run your project from Run -> Run and in the console window you will found the Hello World output.

Option II –

Windows

Text Editor: You can use any simple text editor to type your program. For example you can use Notepad on windows and vim or vi can be used for Linux and Windows as well. Notepad ++ will be a great option for programming text editor.



C++ Compiler: A compiler is used to compile your source code into final executable program. You can use free available compiler like GNU C/C++ compiler, otherwise you can have compilers either from HP or Solaris if you have respective OS.

Installation:

  • Download and Install MinGW installer.

  • Download the latest MinGW version and double click on that installer.


  • After the completion of downloading procedure, select mingw32-gcc-g++ and mingw32-gcc-objc for minimum. You can even select more. Then to install, go to File -> Apply changes.




            • It will install the select files on your computer.

            • After that follow the steps:

            • Head to installation directory of MinGW and then navigate inside the bin folder.

            • Right click on any one of the files stored there.

            • Click on Properties.

            • Copy the location as shown below.

            • Open My computer or The PC. Then from the Home tab Select System properties.

            • Then Navigate to Advanced system settings.

            • In the new window, Click on Environmental Variables.

            • Add a New System variable.

            Variable name- PATH

            Variable Path- C:\MinGW\bin

            • Click on Ok and close all the Windows.


            • Run gcc, g++, ar, ranlib, dlltool, and several other GNU tools from the Windows command line.

            Option III (Windows)Turbo C++

            System Requirements

            • Windows 10, 8.1 and 8.

            • .NET 4.5 Framework.

            How to install?

            1. If any previous turbo C or C++ version install in your computer, then uninstall that.

            2. Extract Turbo "C++ 3.0.zip" file

            3. Run "setup.exe" file.

            4. Follow the instructions.

            How to use?

            1. Install the .exe installer for Turbo C++.

            2. Double click on "Turbo C++" shortcut link on the desktop

            3. If you don't want to open C++ in full screen mode, uncheck the "Full Screen" check box and click "Run Turbo C++"

            4. If you want run Turbo C++ on full screen simply click "Run Turbo C++".

            Option IV –
             
            Microsoft's Visual C++


            If you want to have a complete setup and also want to integrate your C++ programs with debugging then Microsoft's Visual C++ (for Windows), and Code::Blocks (for Linux or Windows) are highly recommended.

            Windows

            • Download Visual Studio Community


            • Double Click on vs_community.exe file.

            • Choose the type of installation as Custom.



            • Unselect All and then only Select Visual C++ option from the Programming Languages. Click on Next.



            • Then it will install the necessary files to complete the IDE setup for C++.



            Linux (or Windows)

            Code::Blocks and Bloodshed's Dev-C++ are preferred as both of them are able to run on Windows, as well as Linux.

            Code::Blocks is a free, open source, cross platform IDE that will run on both Windows and Linux. You can also port between Windows and Linux.

            Mac OSX

            Mac users can use Xcode as the IDE for C++. Xcode is currently available at developer.apple.com/technologies/tools/.

            That's all for IDE. Install and setup whatever you like. But we recommend you to go through the first option i.e. Eclipse IDE which is used to be great development environment and also to be used throughout the session.

            It also helps to find the errors in your programs easily and instantly.