LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-29-2010, 06:13 AM   #1
pallavibhat89
LQ Newbie
 
Registered: Dec 2010
Posts: 10

Rep: Reputation: 0
GCC compiler (c++ compilation)


I am completely new to linux.
Here are few doubts that have been crawling in my mind

as per what i have read,
GCC-is a GNU Compiler Collection
which can compile c codes.
but for compiling c++ codes, we need g++.
according to my knowledge CPP is a pre-processor
but i have been told that cpp is a compiler as well, is it true?
if yes then, can we use cpp to compile c++ codes?

as in, can we use commands like this:
cpp abc.cpp the way we compile .c files (gcc abc.c)


i am using following version
gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-44)

g++ is a part of gcc, but tough gcc is installed, i am unable to see g++ installed.


even if we have cpp, do we need to install g++ or any other c++ compilers?
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 12-29-2010, 06:25 AM   #2
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
As far as I know, cpp is only a preprocessor and not a compiler.

You still need to install g++ to compile C++ programs. The package you need to install will likely be called gcc-c++ or gcc-g++, but check your distribution's package management system (presumably yum or something, since it looks Red Hat based).
 
1 members found this post helpful.
Old 12-30-2010, 12:43 AM   #3
pallavibhat89
LQ Newbie
 
Registered: Dec 2010
Posts: 10

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Nylex View Post
As far as I know, cpp is only a preprocessor and not a compiler.

You still need to install g++ to compile C++ programs. The package you need to install will likely be called gcc-c++ or gcc-g++, but check your distribution's package management system (presumably yum or something, since it looks Red Hat based).
Okay...thanks a lot Nylex
another question is can cpp be used for compiling c++ codes(according to following concept)?
cpp converts C++ files onto a format readable by gcc, n then we can use gcc to compile this converted file.

is this concept of CPP correct (CPP is called using #; and cpp basically includes the contents of header files)?
 
Old 12-30-2010, 03:38 AM   #4
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,680
Blog Entries: 29

Rep: Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917
Read about the Preprocessor here:
http://gcc.gnu.org/onlinedocs/cpp/

Read about cpp here:
http://linux.about.com/library/cmd/blcmdl1_cpp.htm
 
2 members found this post helpful.
Old 12-30-2010, 11:35 PM   #5
pallavibhat89
LQ Newbie
 
Registered: Dec 2010
Posts: 10

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Anisha Kaul View Post
Read about the Preprocessor here:
http://gcc.gnu.org/onlinedocs/cpp/

Read about cpp here:
http://linux.about.com/library/cmd/blcmdl1_cpp.htm
Anisha Thanks a lot for your help
 
Old 12-30-2010, 11:42 PM   #6
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,680
Blog Entries: 29

Rep: Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917
Most welcome, Pallavi, if those links have cleared your doubt, mark the thread solved.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Compiler Benchmarks Of GCC, LLVM-GCC, DragonEgg, Clang LXer Syndicated Linux News 0 11-08-2010 06:11 PM
gcc (GCC) 4.3.2 20081105 (Red Hat 4.3.2-7) compilation error adhesh_19 Red Hat 0 01-05-2010 06:34 AM
have gcc compilation error during gcc installtion in linuxfromscratch vbshanmugaprakash Linux - General 3 12-13-2006 06:52 AM
Kernel compilation error using cross compiler bond_7942 Linux - Software 0 02-02-2005 01:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration