-
help with gcc
Ive been programming in c++ for a while and when i swiched to linux i didnt like any of the programming interfaces, so i wanted to learn to do it in command line. I cannot get ANY programs to work with ANYTHING on linux in C++. Please help!!!!
(yes i know i am a newbie)
-
The command you need is
gcc <source file> -o (output file)
To run the compiled file the command is
./<filename>
Don't forget the "./". I do not believe Linux will check the default directory for the filename you specify. You have to tell it where to look, unless it's specified in your path. I know RedHat does that.
-
To compile C++ programs under Linux, usually you can do so with gcc. From the command line, just type "gcc <program name>" (without the quotes of course). If you need other compilation options, check out the man page, "man gcc".
Hope this helps,
alpha
-
-
its for some reason coming up w/ a compile error ive never seen before... Whats wrong with this source:
#include <iostream.h>
int main()
{
cout << "Hello, World!";
return 0;
}
-
A little more detail here might help. You're basically asking us to fix a leaky basement without telling us where the leak is.
What errors are you getting?
-
ummm... what's the error??
-
the errors are as follows:
undefined refrence to "std::cout"
undefined refrence to "std::basic_ostream <a bunch of vars passed through this arg.>
undefined refrence to "std::iso_base::Init::~Init [in-charge]()"
undefined refrence to "__gxx_personality_v0"
and then it says:
collect2: ld returned 1 exit status
-
Try including the line
using namespace std;
Your code would look like this:
#include <iostream.h>
using namespace std;
int main()
{
cout << "Hello, World!";
return 0;
}
You haven't defined a nemaspace which includes the cout stream yet.
Hope this helps.
/edit
Some compilers add namespaces by default if you don't tell them to. The Gnu C compiler doens't, but it's free, so I never complain about it.
/edit
-
Striek:
i just tried that... no luck.