|
-
October 2nd, 2003, 03:25 AM
#1
Member
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)
You laugh because im different, i laugh because your all the same.
-
October 2nd, 2003, 03:31 AM
#2
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.
Government is like fire - a handy servant, but a dangerous master - George Washington
Government is not reason, it is not eloquence - it is force. - George Washington.
Join the UnError community!
-
October 2nd, 2003, 03:31 AM
#3
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
-
October 2nd, 2003, 03:34 AM
#4
-
October 2nd, 2003, 03:40 AM
#5
Member
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;
}
You laugh because im different, i laugh because your all the same.
-
October 2nd, 2003, 03:54 AM
#6
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?
Government is like fire - a handy servant, but a dangerous master - George Washington
Government is not reason, it is not eloquence - it is force. - George Washington.
Join the UnError community!
-
October 2nd, 2003, 03:54 AM
#7
ummm... what's the error??
-
October 2nd, 2003, 04:03 AM
#8
Member
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
You laugh because im different, i laugh because your all the same.
-
October 2nd, 2003, 04:05 AM
#9
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
Government is like fire - a handy servant, but a dangerous master - George Washington
Government is not reason, it is not eloquence - it is force. - George Washington.
Join the UnError community!
-
October 2nd, 2003, 04:08 AM
#10
Member
Striek:
i just tried that... no luck.
You laugh because im different, i laugh because your all the same.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|