[SOLVED] clarification of "g++ temp.cpp" for newbie
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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"++?
in "temp.cpp", is .cpp generally the extension we use for c++ code before it's compiled?
Yes.
Quote:
Originally Posted by bluegospel
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++
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$
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++
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.