LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   GCC compiler (c++ compilation) (https://www.linuxquestions.org/questions/linux-newbie-8/gcc-compiler-c-compilation-852997/)

pallavibhat89 12-29-2010 05:13 AM

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?

Nylex 12-29-2010 05:25 AM

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).

pallavibhat89 12-29-2010 11:43 PM

Quote:

Originally Posted by Nylex (Post 4206421)
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)?

Aquarius_Girl 12-30-2010 02:38 AM

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

Read about cpp here:
http://linux.about.com/library/cmd/blcmdl1_cpp.htm

pallavibhat89 12-30-2010 10:35 PM

Quote:

Originally Posted by Anisha Kaul (Post 4207467)
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 :)

Aquarius_Girl 12-30-2010 10:42 PM

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


All times are GMT -5. The time now is 03:58 AM.