Searching for best C compiler for compilation?? You must have to stop searching here. gcc/g++: Gross compiler for C /C++ is the best compiler for execution or compilation of c/c++ code. To search best c/c++ compiler is still depends on your, need and platform + operating system you are working on.
GCC Gross compiler work on all platforms from windows –> mac OS –> Linux to your android phone, thats why I am calling it Best Compiler for C/C++.. This post is about compilation and execution of your code using gcc on windows and unix/linux based operating system.
SEE ALSO : Run your code on Android
Compilation on Linux/Unix based Operating System using best c / c++ compiler
Steps for compilation using gcc/g++ compiler:
- GCC is a pre installed compiler in most of the Linux/Unix based O.S , check via: gcc –version or g++ –version.
- If it is not already installed , install it using apt-get command
sudo apt-get install gcc
sudo apt-get install g++ - Write your code using any text editor for example : vi-editor or g-edit (Don’t use #include<conio.h> and getch()) and save it as buffercode.c or buffercode.cpp .
- Open your terminal and type
gcc -o output buffercode.c
or g++ -o output buffercode.cpp - Now run your program on terminal using
./output - All is done 😉
Compilation on Windows using gcc/g++
- Download Mingw and install it by double click on exe file.
- Set Environment variable/path for compilation using your cmd.
go to C drive(Or where it is installed) –>MINGW –>bin and copy it’s path - Open Control Panel –> System –> environment variables(on the left side) –> path
paste their your copied path. - Write your code using Notepad or Notepad++ and save it as buffercode.c or buffercode.cpp (Don’t use #include<conio.h> and getch())
- Open your cmd
Press Window(button) + R and type cmd in run - Go to your file directory using cd command where your c program is saved.
mine is D://program/buffercode.c
cd d:
cd program - Open your terminal and type
gcc -o output buffercode.c
or g++ -o output buffercode.cpp - Now run your program on terminal using
./output - All is done 😉
Compilation using CodeBlock
- Install gcc using above steps either on linux or windows.
- Install codeblock and integrate it .with gcc.
- Write your code ,compile it and execute it.
You can use gcc with several other softwares and applications. Even you can run your code on your android device too using your best C/C++ compiler , off-course it is gcc.
Window users can also go with VS(Visual studio )
Learn C-Programming with buffercode click here to start .