PDA

View Full Version : C++ in Linux



ThePatriot
07-17-2002, 12:57 AM
Well, i finally got redhat working on this old box i had, and read the man pages on gcc and g++, i tried to get a very very simple c++ scipt to work but im having some troubles. The script was basic

#include <iostream.h>

int main()
{
cout<<"Hello" im leaving out endl; cuz it wont work on forums
return 0;
}



ok, so i type it up and save it as hello.cc, then in the console i type in g++ -c hello.cc and it claims it works, but i cant find out where the output of the file is. Any suggestions?

SlipknotX556
07-17-2002, 02:54 AM
Yhea you got it working on my old box.

alkafluence
07-17-2002, 08:42 AM
Try the -o flag and then specify the file name you want it to come out as. If you don't specify the name or the -o flag the output file will be "a.out."

(an example for a c compilation)
gcc -o fileiwant sourcefile.c

This will produce an executable file called "fileiwant."

314159
07-18-2002, 02:53 PM
do u mean

#include<iostream.h>

int main()
{
cout<<"Hello, im leaving, out"<<endl; //cuz it wont work on forums
return 0;
}

314159
07-18-2002, 02:54 PM
hehe, i see that this board has a way of "editing" your text

hehehehe

ThePatriot
07-18-2002, 03:49 PM
Yea it does, i tried to put < < endl; in but it kept editing it so i gave up.

lopxtc
07-18-2002, 05:19 PM
No you use the -o flag with the g++ command .. that specifies the name and location of the out file. Without that flag it creates a binary named a.out


Aaron

314159
07-19-2002, 09:23 AM
is your rl name Aaron?..... if so, then there are too many of us out there O_o

alkafluence
07-22-2002, 09:39 AM
Originally posted by lopxtc
No you use the -o flag with the g++ command .. that specifies the name and location of the out file. Without that flag it creates a binary named a.out


Aaron
That's what I said...



If you don't specify the name or the -o flag the output file will be "a.out."


In other words if you don't put it there ----> it gives you "a.out"