Saturday, 29 November 2014

GCC Compiler

GCC:

About: The GNU Compiler Collection (GCC) is a compiler system produced by the GNU Project supporting various programming languages. GCC is a key component of the GNU toolchain. The Free Software Foundation (FSF) distributes GCC under the GNU General Public License (GNU GPL). GCC has played an important role in the growth of free software, as both a tool and an example.

Link:download

Installing TDM GCC Compiler

Click on Create and uncheck "check for updates" if you dont have active internet connection

Choose the edition of installation based on your OS(32-bit or 64-bit). If you are not sure what to choose go for 32-bit

Choose Your Installation directory

Installation Completed

Compiling Programs


we can compile our C or C++ program using two ways


1) Without any IDE(using your favorite text editior and cmd)
2) With an IDE.

Without IDE(complicated)


step1:: Write your c or c++ code using any text editor but save it with .c or .cpp extension.

step2:: Before Compiling set path to the directory of gcc bin folder in your sys variables. In my case it is C:\TDM-GCC-32\bin

step3:: Now open your command prompt or cmd. Change the directory in which your c or c++ file is saved.

step4:: To compile a C file use command " gcc filename.c " To compile a C++ file use command " g++ filename.cpp" (if you have errors it will show and correct the source code)

step5:: After Successfull Compilation, Simply type " a " to Run the program.

With IDE.(using Code::Blocks)


About: Code::Blocks is a free and open source, cross-platform IDE which supports multiple compilers including GCC, Clang and Visual C++. It is developed in C++ using wxWidgets as the GUI toolkit.

Link:download

Installing Code::Blocks

Starting Page of Code::Blocks

After Installing Code::Blocks open it.
It will Automatically detect TDM GCC compiler

Create a new file using file->new->file

Choose File type(c or c++)

Give Filename with Full Path
Creating first.c file

first.c

Sample Program

Errors and warnings are shown at the bottom in logs and others section

Creating second.cpp file

Sample c++ Program
Click F9 to build and run

Output

No comments:

Post a Comment