[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Error: undefined reference to
From: |
Guy Harrison |
Subject: |
Re: Error: undefined reference to |
Date: |
Thu, 04 Nov 2004 11:59:15 GMT |
User-agent: |
KNode/0.7.7 |
Ben Rennigen wrote:
> Hi,
>
> "Guy Harrison" <swamp-DEL-dog@ntlworld.com> schrieb im Newsbeitrag
> news:0k3cmc.ebj1.ln@sd-if.swampdog...
>
>> ...but not supplied the code body (definition). This may be because
>> you've not written it at all or because you've not passed the
>> object-file/lib containing the definition to the linker.
>
> this may be the error - I compile the code with:
>
> "g++ prog_complex.cpp -o prog_complex"
>
> So there are no information about any object file or lib. I think my
> compile - commandline isn't correct, how can I tell the compiler/linker to
> link the object file of the file containing my complex-class
> implementation?
$ g++ -o prog_complex prog_complex.cpp foo.o
...assuming foo.cpp having been subject to
$ g++ -c foo.cpp
If you've built a library then (eg: man, search for '-L' and '-l') "-L.
-lfoo" would be in order (for libfoo.* - eg: libfoo.so/libfoo.a).
Fwiw...
$ g++ -o prog_complex prog_complex.cpp foo.cpp
...will work. Obviously the compiler is possibly being made to recompile
when it may not ought (hint: "man [g]make" and gcc -M? option).
Re: Error: undefined reference to, Ulrich Eckhardt, 2004/11/04