 |
 |
learning c++
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Nov 2001
Status:
Offline
|
|
i don't know anything about C++ so can anyone tell me why am I getting....
/usr/bin/ld: Undefined symbols:
___ls__7ostreamPCc
_cout
...when I try to compile...
#include <iostream.h>
void main()
{
cout << "Hello World.";
}
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Nov 2000
Location: The voice inside your head
Status:
Offline
|
|
I'm having exactly the same problem, cc doesn't seem to like cout and cin for some reason.
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Nov 2000
Location: The voice inside your head
Status:
Offline
|
|
Gah, a search of the forum archives shows that you need to use the command c++ instead of cc when compiling c++ programs in the command line.
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Apr 2001
Location: Bethesda, MD
Status:
Offline
|
|
Originally posted by lythari:
<STRONG>Gah, a search of the forum archives shows that you need to use the command c++ instead of cc when compiling c++ programs in the command line.</STRONG>
Yup, when you use "cc" the compiler assumes is a C program and so it links with the C libraries. cin and cout are C++ constructs, so you need to compile with "c++". They're the essentially the same program, but they invoke the linker, "ld" different.
dave
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Nov 2001
Status:
Offline
|
|
ah yes, that seems to be it... thank you and thank you.
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Nov 2000
Status:
Offline
|
|
This is for those who might be interested in what is going on.
c++ passes the '-lstdc++' flag on to the linker. 'c++ -o foo foo.c' and 'cc -o foo foo.c -lstdc++' work equally well.
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Nov 2000
Status:
Offline
|
|
Double post. Move along, nothing to see here.
[ 01-14-2002: Message edited by: int69h ]
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |