newbie linker error - 'undefined reference'
I want to compile, and then link, even. (Imagine that.) I think my
basic problem is how to learn what libraries to include on my link command
line.
Here's my first attempt at building a program from scratch on my slink
system:
t.cc:
#include <fstream.h>
int main (int argc, char *argv[])
{
cout << argv[1];
return 0;
}
Makefile:
t: t.o
t.o: t.cc
Emacs compilation buffer:
make -k
g++ -c t.cc -o t.o
cc t.o -o t
t.o: In function `main':
t.o(.text+0xd): undefined reference to `cout'
t.o(.text+0x12): undefined reference to `ostream::operator<<(char const
*)'
make: *** [t] Error 1
This is a linker unresolved reference, right? I need to pass a command
line switch to the linker to tell it the library, right?
Okay, how can I relate a given header (e.g. fstream.h) with the library or
libraries that house the functions published by the header? Is there a
../doc/.. area that I haven't found? Should I use ld to scan all
library directories searching for functions names?
Thanks,
Matt Miller
-----------------------------------------------------------------------
'The number of UNIX installations has grown to 10, with more expected.'
- The UNIX Programmer's Manual, 2nd Edition, June, 1972
Reply to: