LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-30-2010, 01:43 PM   #1
bluegospel
Member
 
Registered: Jan 2010
Distribution: centOS
Posts: 404

Rep: Reputation: 53
clarification of "g++ temp.cpp" for newbie


Okay, I'm just getting started with C++ (without any prior C experience), and I'm confronted by the following instruction:

--------------------------
If you execute the compiler directly, without using the shell file, its behavior is more relaxed. This may sometimes be necessary. Do it like this:


g++ temp.cpp
Now set up a convenient data directory in which to place your programs. Create a file named temp.cpp with this content:


#include <iostream>

using namespace std;

int main()
{
cout << "Hello World!" << endl;
return 0;
}
Again, you should be able to copy this little program from this page, and use a text editor to save it as “temp.cpp.”

Move to the directory in which temp.cpp is located, and type this:


gccp temp.cpp
--------------------------

What is happening with "g++ temp.cpp" (near the very beginning of this excerpt), and why do we call it "g"++?
 
Old 06-30-2010, 01:46 PM   #2
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
g++ is the name of the GNU C++ Compiler in Linux.

gcc is the name of the GNU C Compiler in Linux.

The G in GNU recursively stands for itself and ultimately doesn't stand for anything else.

If I understand your question, your focus was on why "G"? If so, I don't have an answer much better than don't worry about it.

Last edited by johnsfine; 06-30-2010 at 01:50 PM.
 
Old 06-30-2010, 01:56 PM   #3
bluegospel
Member
 
Registered: Jan 2010
Distribution: centOS
Posts: 404

Original Poster
Rep: Reputation: 53
Thanks.

Actually, I understand the "Gnu's Not UNIX" acronym. You're explanation is just what I was after.

But in "temp.cpp", is .cpp generally the extension we use for c++ code before it's compiled?
 
Old 06-30-2010, 01:59 PM   #4
bluegospel
Member
 
Registered: Jan 2010
Distribution: centOS
Posts: 404

Original Poster
Rep: Reputation: 53
What's the difference between "g++ temp.cpp" near the beginning and "gccp temp.cpp" near the end?
 
Old 06-30-2010, 02:09 PM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Maybe just a variant of the same thing?

Try both versions to see if they work. If so, then one might be a soft link to the other---or an alias.
 
Old 06-30-2010, 02:12 PM   #6
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by bluegospel View Post
in "temp.cpp", is .cpp generally the extension we use for c++ code before it's compiled?
Yes.

Quote:
Originally Posted by bluegospel View Post
What's the difference between "g++ temp.cpp" near the beginning and "gccp temp.cpp" near the end?
I don't know what gccp is. Maybe a typo.

Some systems have gpp installed as a link or alias for g++ so that it can be called by older scripting tools that don't understand g++ can be a program name. Maybe someone set up gccp as a similar alias for g++

Last edited by johnsfine; 06-30-2010 at 02:14 PM.
 
Old 06-30-2010, 02:25 PM   #7
bluegospel
Member
 
Registered: Jan 2010
Distribution: centOS
Posts: 404

Original Poster
Rep: Reputation: 53
Does this give an answer?:

sh-3.1$ which gccp
which: no gccp in (/usr/local/bin:/usr/bin:/bin:/usr/games:/usr/lib/java/bin:/usr/lib/kde4/libexec:/usr/lib/qt/bin:/usr/share/texmf/bin:.)
sh-3.1$ locate gccp
/usr/lib/gcc/i486-slackware-linux/4.3.3/adalib/libgccprefix.a
sh-3.1$ file /usr/lib/gcc/i486-slackware-linux/4.3.3/adalib/libgccprefix.a
/usr/lib/gcc/i486-slackware-linux/4.3.3/adalib/libgccprefix.a: current ar archive
sh-3.1$
 
Old 06-30-2010, 02:30 PM   #8
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by bluegospel View Post
Does this give an answer?:
To what question? It answers Pixellany's suggestion that you try both.

I get the same result when I try which gpp. But that does not mean the place I saw gpp used as an alias for (via soft link to) g++ was a typo. It just means that soft link isn't installed in the Linux system I'm using now.

My guess is that gccp was a typo. But I could easily be wrong. Second best guess is that it was a soft link installed on the system used by whoever wrote the instructions you quoted.

Whatever it was, there is no reason for you to use it. Use g++

Last edited by johnsfine; 06-30-2010 at 02:31 PM.
 
Old 06-30-2010, 04:21 PM   #9
bluegospel
Member
 
Registered: Jan 2010
Distribution: centOS
Posts: 404

Original Poster
Rep: Reputation: 53
I tried both and it appears Johnsfine is right--either it's a typo or the author overlooked a prior use of a soft link.

I'm marking this solved. Thanks!
 
  


Reply



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
seeking "geek stick" USB drive clarification SaintDanBert Linux - Hardware 3 02-01-2010 09:31 AM
newbie question: whats the difference between "su root", "su" and "su -&quo mojarron Slackware 9 12-07-2009 04:08 PM
Easy Peasy's "temp" version (including FF issues) Asinine Linux - Distributions 3 08-12-2009 06:11 PM
boot hung @ "probing for PCIC" (temp fix) ccm13 Linux - Laptop and Netbook 1 03-21-2007 10:16 PM
Clarification on the term "embedded linux" lanclamas Linux - General 2 03-30-2004 09:40 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:36 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
Open Source Consulting | Domain Registration