[Gllug] c++ newbie complier probs

Stig Brautaset stigbrau at start.no
Tue Oct 22 21:30:29 UTC 2002


On Oct 22 2002, Sean wrote:
> Pete Ryland wrote:
> 
> >On Tue, Oct 22, 2002 at 08:43:25PM +0100, Sean Burlington wrote:
> >
> >>I am using gcc 3.1
> >>/usr/local/bin/g++ -Wall \
> >>-I/home/sean/projects/c++/bb/horstman/cccfiles/  4.cpp
> >>
> >>and get the following output
> >>(I'm confused - other programs using the same included files work fine
> >>I think I am missing something obvious )
> >>
> >>/tmp/ccLFm4QL.o: In function `same_name(Employee, Employee)':
> >>/tmp/ccLFm4QL.o(.text+0x18): undefined reference to
> >>`Employee::get_name() const'
> >>/tmp/ccLFm4QL.o(.text+0x2a): undefined reference to
> >>`Employee::get_name() const'
> >>/tmp/ccLFm4QL.o: In function `main':
> >>/tmp/ccLFm4QL.o(.text+0xf8): undefined reference to
> >>`Employee::Employee[in-charge](std::basic_stringstd::char_traits, 
> >std::allocator >, double)'
> >>/tmp/ccLFm4QL.o(.text+0x18e): undefined reference to
> >>`Employee::Employee[in-charge](std::basic_stringstd::char_traits, 
> >std::allocator >, double)'
> >>collect2: ld returned 1 exit status
> >
> >
> >These are linker errors.  Add a "-c" to your g++ line to just compile to a
> >.o file instead.
> >
> >Pete
> >
> thanks Pete
> 
> It does complie without error if I do that
> 
> I kind of wanted an executable though ...

You either have to give the compile your source together with the
source of the file where the class Employee is defined, or link your .o
with the precompiled object file of the source that implements the
Employee class.

PS: rough guessing, I don't know C++ either.


Stig
-- 
brautaset.org

-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list