Linux - NewbieThis 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
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.
if iostream.h is not detected then there s some thing wrong with your package.try to load new version from the slackware site...thats all i can say....good luck
The first problem I see is that your using the old header files. The new standard header files do not include the .h at the end. The next error I see is that your not declaring the namespace for the functions cout and endl. Try this code out.
PHP Code:
#include <iostream> // notice how it does not have the .h using namespace std; // this is how you use a namespace /* you could also do this: using std::cout; using std::endl;
This is the better way to do as your not using the entire std namespace. */
int main() { cout << "Hi" << endl; return 0; // returning anything besides a 0 indicates an error. }
it does compile now.......... I write:
g++ test.c -o me.out
and it will create me.out
but I type me or me.out and it keeps saying:
bash: me.out: command not found
but the file is there I see it with ls
HI
It just keeps saying file doesn't exist even when I use
g++ test.c -o me.out
it creates me.out and I try:
me.out./ as you said and it won't work.
If I compile using g++ it does create the out. but if I try cc or gcc it says iostream doesn't exist and cout, endl and namespace should be declared first.
Is it possible I didn't install Red Hat correctly? I see everyone compiles just fine
I can compile now!
thanks a lot to everyone.......... why do I have to use a ./ in front of the file?
I'm used to C++ under Windows..... but I don't know whats about *.out files...... if I try to write something a little more complicated (ie I use several .h and .cpp files) how can I join them into one exe?
thanks thanks thanks a lot I really appreciate it.
hi,
i would suggest that u try using ./
first of all,try to get the object file as it is,i.e compile using the basic command
g++ file.cpp
no g++ -o..... etc.
if the compiling went fine(as u have told)
u should be able to find a file a.out in your directory.
now type ./a.out to run the program.
now why to use ./ in front............
from what i have heard,object files are executed using the ./ command in front of the name of the file.(try to get output atleast usiong this)
now to run several cpp files together,from what i have heard
it is enough to compile them together.
i.e
g++ file1.cpp file2.cpp .................
(please reconfirm on this and post the answer)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.