This is the mail archive of the
mailing list for the Cygwin project.
Re: undefined reference to 'class::function' error
Please don't Cc: me, I read the list (I set the Reply-To: for a reason).
On Fri, 10 Oct 2003, Kai Xu (Kevin) wrote:
> As I am not good at c++, I am not sure what you mean by "link the file that
> defines this function into the resulting executable". I just include the .h
> file that defines the function in the main .cpp file. The compile command I
> used is:
> g++ sp.cpp (the main cpp file)
> I guess there could be some problem here.
Aha, so you aren't linking the file in. This is a general C/C++ question,
not Cygwin specific, and thus off-topic for this list. For more details,
read up on "separate compilation" and "multiple source files" in any C/C++
book. For a short term solution, simply add the cpp file that defines the
missing function to the compile command, but if you need further help on
similar issues, please try a C/C++ user support list/newsgroup or read
an intro to programming book.
> ----- Original Message -----
> From: "Igor Pechtchanski" <firstname.lastname@example.org>
> To: "Kai Xu (Kevin)" <email@example.com>
> Cc: <firstname.lastname@example.org>
> Sent: Thursday, October 09, 2003 11:53 PM
> Subject: Re: undefined reference to 'class::function' error
> > On Thu, 9 Oct 2003, Kai Xu (Kevin) wrote:
> > > I guess I can only post a example of the errors here, as the main
> > > program is about 2k lines and compiler doesn't tell where the error
> > > occurs.
> > >
> > > I am not good at c++ and this is not my program, so please let me
> > > know if I am not posting the right thing or anything is missing.
> > >
> > > Cheers,
> > > Kevin
> > >
> > > The error message:
> > > undefined reference to `NList::insert(Cone*, double, int)'
> > > [snip]
> > Ok, so it's a linking error. Is the file that defines this function
> > linked into the resulting executable? Can you please post the exact
> > command used to invoke the compiler to link the final executable?
> > Igor
|\ _,,,---,,_ email@example.com
ZZZzz /,`.-'`' -. ;-;;,_ firstname.lastname@example.org
|,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D.
'---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow!
"I have since come to realize that being between your mentor and his route
to the bathroom is a major career booster." -- Patrick Naughton
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html