C++ - SPLessons

C++ Set Environment Variable

Home > Lesson > Chapter 2
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

C++ Set Environment Variable

C++ Set Environment Variable

shape Introduction

To setup C++ environment, a tool set that contains "Compiler, Archiver and Linker" is available (for libraries) which are clearly explained in the current chapter "CPP Set Environment Variable".

Compiler

Compiler is a program which converts the source code(human understandable) to the object code i.e. it has machine executable code and special symbols(computer understandable).

Archiver

The compiler produced files are first sent to Archiver and sends to the static libraries wherein the object files are arranged properly.

Linker

The linker inputs these arranged object files, resolves any issues and gives an executable library file which can be executed by any operating system. Compiler is required to execute any C++ program and various compilers are also available. Dev C++ is a free compiler used in Windows and Linux. Using this compiler, the user can compile and execute C and C++ programs. It is available with GCC compiler.Below are the steps to download and install Dev-C++ Compiler.

Steps to install Dev C++ are as follows

shape Step - 1

Below are the steps to CPP Set Environment Variable : Download .exe file of Dev-C++ IDE and double click on the downloaded file( .exe file). When clicked on the file, compiler will unzip the files and asks to select a language.Select any of the required language and click on OK.By default, English is chosen.

shape Step - 2

Start the installation by clicking "I Agree" which tells to accept the licence agreement. Click on "Next" by choosing the necessary components like below. Choose the destination folder by using "Browse" and click on "Install" button. Installation will be in progress as shown below. After installation completes, click on Finish as shown below.

shape Step - 3

After completion of installation set the path. To set the path on Windows 7, go to My Computer -> Right click on My Computer -> Properties -> Advance System Settings (1) To set the path on Windows 8, right click on Windows icon -> System -> Advanced system settings  (2) Choose Advanced tab. (3) Click on Environment Variables. (4) Now select Path in the list of System Variables. (5) Click on Edit button. (6) A pop-up window opens asking for path variable details. Give the variable name : Path Variable value : C:\Dev-Cpp\MinGW64\bin (destination address) Do not forget to place semicolon(;) before copying the bin directory location into variable value. (7)Click OK on all the windows opened.

shape Step - 4

Once the installation is done then start the compiler by opening it. Go to File -> New -> Project. Then, select Console Application. Choose “C++ Project” and “Make Default Language” check box if needed.

shape Step - 5

Click on File->New->Source file, type a sample program and save it as "sample.cpp". [c] #include<iostream> using namespace std; int main() { cout << "Hello World" << endl; return 0; } [/c] On Menu bar, click “Compile & Run” or "F11" to compile and execute program.Output will be displayed on black command window as below.

Summary

shape Key Points

CPP Set Environment Variable chapter draws out the following important points.
  • Compiler converts source code to executable code.
  • Dev C++ is best compiler to run C++-Programs
  • Path is set either permanently or temporarily

shape Programming Tips

Ensure to set the path once the installation is completed.
Now its time to learn C++ -language.