![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the difference between g++ and gcc?
g++
GNU C++ Compiler ( g++ ) is a compiler in Linux which is used to compile C++ programs. It compiles both files with extension .c and .cpp as C++ files.
The following is the compiler command to compile C++ program.
g++ program.cpp -o filename
Here,
filename − The name of file with .c or .cpp extension.
The following is an example of using g++ compiler.
Example
#include <iostream> using namespace std; int main() { int a = 20; cout << "The value of a : " << a; return 0; }
Output
$g++ -o main *.cpp $main The value of a : 20
gcc
GNU C Compiler ( gcc ) is a compiler in Linux which is used to compile C programs. It compiles files with extension “.c”.
The following is the compiler command to compile C program.
gcc program.c -o filename
Here,
filename − The name of file with .c extension.
The following is an example of using gcc compiler.
Example
#include <stdio.h> int main() { int a = 20; printf("The value of a : %d", a); return 0; }
Output
$gcc -o main *.c $main The value of a : 20
Advertisements