This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: undefined reference, plz help
- From: Pavel Tolkachev <paultolk at yahoo dot com>
- To: gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Thu, 9 Jun 2011 18:20:47 -0700 (PDT)
- Subject: Re: undefined reference, plz help
- Reply-to: paulTolk at yahoo dot com
--- On Thu, 6/9/11, Brian Budge <brian.budge@gmail.com> wrote:
> From: Brian Budge <brian.budge@gmail.com>
> Subject: Re: undefined reference, plz help
> To: "eric lin" <ericlin@fsshl.zzn.com>
> Cc: gcc-help@gcc.gnu.org
> Date: Thursday, June 9, 2011, 8:52 AM
> On Wed, Jun 8, 2011 at 9:26 PM, eric
> lin <ericlin@fsshl.zzn.com>
> wrote:
> >
> > Dear gcc programers:
> >
> > ?what may cause compile error (on 4.5.2 or maybe
> not)
> > ------
> > ?g++ pg49.cpp
> > /tmp/ccUvNoPf.o: In function `main':
> > pg49.cpp:(.text+0x42): undefined reference to
> `IntArray::IntArray(int*, int)'
> > pg49.cpp:(.text+0x5e): undefined reference to
> `IntArrayRC::IntArrayRC(int*, int)'
> > /tmp/ccUvNoPf.o: In function `IntArray::~IntArray()':
> >
> pg49.cpp:(.text._ZN8IntArrayD2Ev[_ZN8IntArrayD5Ev]+0xb):
> undefined reference to `vtable for IntArray'
> > /tmp/ccUvNoPf.o: In function
> `IntArrayRC::~IntArrayRC()':
> >
> pg49.cpp:(.text._ZN10IntArrayRCD2Ev[_ZN10IntArrayRCD5Ev]+0xb):
> undefined reference to `vtable for IntArrayRC'
> > collect2: ld returned 1 exit status
> > --------
> > eric ?/* I am happy to supply code I compiled, plz
> show up your private email address or email me privately */
> >
> >
> >
> >
>
> This means that you've declared, but not defined those
> constructors.
> At link time, the linker cannot find the code for those
> functions.
>
> ? Brian
>
Just a small correction: these are destructors or other virtual functions that are undefined, not constructors.
HTH
-Pavel