C - Environment Setup

No comments
In this tutorial we will tell you what are the things required to install on your system for compiling and running C programs on your system properly.In this tutorial we will go over all the detailed steps required for compiling and running C programs on various operating systems, and you can choose any one of them depending on the operating system you are using.
programs on your system then you will need at least two softwares.
1.A text editor   2.C compiler

1.Text Editor –
You can use any text editor as per your convenience. Text editor will be used to write the program usually called source code which we will compile. The text file is saved with a .c extension for compilation.
The text editor used can vary for different operating systems.
For windows we usually use Notepad and vi or vim can be used for LINUX or UNIX Operating systems.

2.C Compiler-
The basic requirement of any programming language is it’s compiler .Like all other programming languages C also has compiler which converts the programmer written code (Source code) to a code which computer understands(Object code), and creates an executable file.
There are many free easily available compilers like GCC, GNU ,C/C++ for various operating system.

Installing A C compiler –
Here is a guide which will tell you how to install GNU or C/C++ compiler on various operating systems.

Installing A C Compiler On  LINUX/UNIX-

Is GCC already installed on your system?
To check whether GCC already installed on your LINUX/UNIX system,try following code on command line-

$ gcc –v
The following message will print if your system has already GCC compiler installed.
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr .......
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)
If not installed- If compiler is not installed on your system then you have to install it on your own.
Follow the link below for detailed information-


Installing A C Compiler On  Mac
The easies way to get GCC for a MAC OS X is to download Xcode from apple’s website which provides all the installation steps.
Follow this link to get the Xcode- developer.apple.com/technologies/tools/.
With Xcode you can use GNU compiler for C/C++. 

Installing A C Compiler On  Windows -
1.Using GCC compiler
For windows we will use a very simple and easy to use compiler named ‘GCC’.

Note-1.GCC is just a compiler  which can compile both C and C++ programs ,it isn’t a IDE(Integrated Development System) like Turbo C++ and some other IDEs.
2.We will use command prompt for compiling and running C or C++ programs on windows ,which is a good practice for beginners.

Follow these steps to download and install GCC compiler for windows-
Step 1.  go to the link  http://sourceforge.net/projects/mingw/files/ .

Step 2.    Click on the link Check the line “Looking for the latest version? “Download mingw-get-setup.exe (86.5 kB)” for downloading the latest version.

Step 3.  After Completing the download run the .exe file.(You can find the shortcut on desktop).

Step 4.  Go to “All package” and choose all the GNU C Compiler listed in the window.(screenshot is shown below).





Note: You can choose the GNU C++ compiler if you want to compile C++ programs .


Step 5.  Click on Installation and Apply Changes, and the required files will start downloading.

Step 6.  Setting Path- Right-Click on my Computer >Properties > Advanced System Settings >Environment Veriables
2.&Now in system variables go to path and edit
3.Copy and paste the path of the bin folder (C:\MinGW\bin;) as shown in the image below.



Step 7.   Restart your system and open command prompt(windows+R, and type cmd then ENTER).
Step 8.  Is GCC installed in your machine?
Type the command
gcc --version
and following output will show.



Which means you have successfully installed GCC compiler on your windows, and now you can easily compile C programs.

2.Using Turbo C++ IDE
 1.Follow the link given below  to download Turbo C++ compiler for your windows.


2.Unzip the file and install it on your system.
3.Setting path-Now we need to set the path for this compiler.
Right-Click on my Computer >Properties > Advanced System Settings >Environment Veriables
Now in system variables copy and paste  the path of bin of the turbo c++ compiler,as highlited in the figure below.




Now it is done ,we have successfully installed the compiler on our system for compiling and running the C programs.  Also we have set the path for it, so we can run various commands on command line

No comments :

Post a Comment