public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* RE: undefined reference to `x'
@ 2006-08-02 18:28 Alex Triffitt
  2006-08-02 20:30 ` Tony Wetmore
  2006-08-02 20:32 ` Michael Eager
  0 siblings, 2 replies; 8+ messages in thread
From: Alex Triffitt @ 2006-08-02 18:28 UTC (permalink / raw)
  To: Michael Eager; +Cc: gcc-help

drawWindow.cpp,  contains the following

drawWindow::drawWindow(vizManager* passedPtr)
{
  DRAW_topoFactory = new TOPO2D_Factory();
  DRAW_raycaster = new TOPO2D_Raycaster(DRAW_topoFactory);
  resetDrawWindow();
  managerPtr = passedPtr;
} // end of drawWindow constructor


drawWindow::~drawWindow()
{
}

Cheers Alex



----------------------------------------
> Date: Wed, 2 Aug 2006 10:11:52 -0700
> From: eager@eagercon.com
> To: alextriffitt@hotmail.com
> CC: gcc-help@gcc.gnu.org
> Subject: Re: undefined reference to `x'
> 
> Alex Triffitt wrote:
> > I am trying to compiled a rather complicated program. And I am constantly getting the error:
> > "undefined reference to `<x>'" where x is a function in a class. For example I have the file vizManager.cpp which has at the very top the statment #include "drawWindow.h". Within vizManager.cpp there is a call to create a drawWindow object through the line "drawWindow(this)". The vizManager.cpp file compiles perfectly fine but when it comes to linking with the line:
> > 
> > g++ -g -o iNSpect configFile.o eventBuilder.o vizNodeList.o vizNode.o vizLine.o iNSpect.o vizProperties.o simWindow.o toolkitWindow.o vizManager.o nodeStats.o -pthread -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lgthread-2.0 -lglib-2.0   -Wl,--export-dynamic -lgtkglext-x11-1.0 -lgdkglext-x11-1.0 -lGLU -lGL -lgtk-x11-2.0 -lpangox-1.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0
> > 
> > I get the following error;
> > 
> > vizManager.o: In function `~vizManager':/home/triff/inspect-triff-beta/src/vizManager.cpp:99: undefined reference to `drawWindow::~drawWindow()'
> > :/home/triff/inspect-triff-beta/src/vizManager.cpp:99: undefined reference to `drawWindow::~drawWindow()'
> > vizManager.o: In function `vizManager':/home/triff/inspect-triff-beta/src/vizManager.cpp:51: undefined reference to `drawWindow::drawWindow(vizManager*)'
> > :/home/triff/inspect-triff-beta/src/vizManager.cpp:84: undefined reference to `drawWindow::~drawWindow()'
> > :/home/triff/inspect-triff-beta/src/vizManager.cpp:51: undefined reference to `drawWindow::drawWindow(vizManager*)'
> > :/home/triff/inspect-triff-beta/src/vizManager.cpp:84: undefined reference to `drawWindow::~drawWindow()'
> > 
> > The only way I have found around this is by adding the following lines near the top of vizManager.cpp:
> > 
> > drawWindow::drawWindow(vizManager*)
> > {
> > }
> > drawWindow::~drawWindow()
> > {
> > }
> > 
> > This I don't think actually fixes the problem because then these functions are called do nothing and therefore cause a lot of errors.
> > 
> > Does anyone know what is going wrong? Is this a linking problem? Or a library problem? or something totally different. I suspect this is something to do with the fact I am trying to compile using GCC version 4.1.0 when the program was orginally written for an earlier version.
> 
> How are the constructors and destructor for the drawWindow class
> declared and defined?
> 
> My guess is that you only have these declared in the class,
> without providing bodies for the member functions.
> 
> 
> 
> -- 
> Michael Eager	 eager@eagercon.com
> 1960 Park Blvd., Palo Alto, CA 94306  650-325-8077

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: undefined reference to `x'
  2006-08-02 18:28 undefined reference to `x' Alex Triffitt
@ 2006-08-02 20:30 ` Tony Wetmore
  2006-08-02 20:32 ` Michael Eager
  1 sibling, 0 replies; 8+ messages in thread
From: Tony Wetmore @ 2006-08-02 20:30 UTC (permalink / raw)
  To: Alex Triffitt; +Cc: gcc-help

Alex,

Should drawWindow.o be linked with your application?  I do not see it in 
your original message, which would explain the error.

Unless, of course, that object file is contained within one of the 
libraries.  If so, please ignore this message. :)

--
Tony Wetmore
Solipsys Corporation (http://www.solipsys.com)
mailto:tony.wetmore@solipsys.com


Alex Triffitt wrote:
> drawWindow.cpp,  contains the following
> 
> drawWindow::drawWindow(vizManager* passedPtr)
> {
>   DRAW_topoFactory = new TOPO2D_Factory();
>   DRAW_raycaster = new TOPO2D_Raycaster(DRAW_topoFactory);
>   resetDrawWindow();
>   managerPtr = passedPtr;
> } // end of drawWindow constructor
> 
> 
> drawWindow::~drawWindow()
> {
> }
> 
> Cheers Alex
> 
> 
> 
> ----------------------------------------
>> Date: Wed, 2 Aug 2006 10:11:52 -0700
>> From: eager@eagercon.com
>> To: alextriffitt@hotmail.com
>> CC: gcc-help@gcc.gnu.org
>> Subject: Re: undefined reference to `x'
>>
>> Alex Triffitt wrote:
>>> I am trying to compiled a rather complicated program. And I am constantly getting the error:
>>> "undefined reference to `<x>'" where x is a function in a class. For example I have the file vizManager.cpp which has at the very top the statment #include "drawWindow.h". Within vizManager.cpp there is a call to create a drawWindow object through the line "drawWindow(this)". The vizManager.cpp file compiles perfectly fine but when it comes to linking with the line:
>>>
>>> g++ -g -o iNSpect configFile.o eventBuilder.o vizNodeList.o vizNode.o vizLine.o iNSpect.o vizProperties.o simWindow.o toolkitWindow.o vizManager.o nodeStats.o -pthread -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lgthread-2.0 -lglib-2.0   -Wl,--export-dynamic -lgtkglext-x11-1.0 -lgdkglext-x11-1.0 -lGLU -lGL -lgtk-x11-2.0 -lpangox-1.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0
>>>
>>> I get the following error;
>>>
>>> vizManager.o: In function `~vizManager':/home/triff/inspect-triff-beta/src/vizManager.cpp:99: undefined reference to `drawWindow::~drawWindow()'
>>> :/home/triff/inspect-triff-beta/src/vizManager.cpp:99: undefined reference to `drawWindow::~drawWindow()'
>>> vizManager.o: In function `vizManager':/home/triff/inspect-triff-beta/src/vizManager.cpp:51: undefined reference to `drawWindow::drawWindow(vizManager*)'
>>> :/home/triff/inspect-triff-beta/src/vizManager.cpp:84: undefined reference to `drawWindow::~drawWindow()'
>>> :/home/triff/inspect-triff-beta/src/vizManager.cpp:51: undefined reference to `drawWindow::drawWindow(vizManager*)'
>>> :/home/triff/inspect-triff-beta/src/vizManager.cpp:84: undefined reference to `drawWindow::~drawWindow()'
>>>
>>> The only way I have found around this is by adding the following lines near the top of vizManager.cpp:
>>>
>>> drawWindow::drawWindow(vizManager*)
>>> {
>>> }
>>> drawWindow::~drawWindow()
>>> {
>>> }
>>>
>>> This I don't think actually fixes the problem because then these functions are called do nothing and therefore cause a lot of errors.
>>>
>>> Does anyone know what is going wrong? Is this a linking problem? Or a library problem? or something totally different. I suspect this is something to do with the fact I am trying to compile using GCC version 4.1.0 when the program was orginally written for an earlier version.
>> How are the constructors and destructor for the drawWindow class
>> declared and defined?
>>
>> My guess is that you only have these declared in the class,
>> without providing bodies for the member functions.
>>
>>
>>
>> -- 
>> Michael Eager	 eager@eagercon.com
>> 1960 Park Blvd., Palo Alto, CA 94306  650-325-8077
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: undefined reference to `x'
  2006-08-02 18:28 undefined reference to `x' Alex Triffitt
  2006-08-02 20:30 ` Tony Wetmore
@ 2006-08-02 20:32 ` Michael Eager
  1 sibling, 0 replies; 8+ messages in thread
From: Michael Eager @ 2006-08-02 20:32 UTC (permalink / raw)
  To: Alex Triffitt; +Cc: gcc-help

That is how they are defined.
How are they declared within the class?

Alex Triffitt wrote:
> drawWindow.cpp,  contains the following
> 
> drawWindow::drawWindow(vizManager* passedPtr)
> {
>   DRAW_topoFactory = new TOPO2D_Factory();
>   DRAW_raycaster = new TOPO2D_Raycaster(DRAW_topoFactory);
>   resetDrawWindow();
>   managerPtr = passedPtr;
> } // end of drawWindow constructor
> 
> 
> drawWindow::~drawWindow()
> {
> }
> 
> Cheers Alex
> 
> 
> 
> ----------------------------------------
>> Date: Wed, 2 Aug 2006 10:11:52 -0700
>> From: eager@eagercon.com
>> To: alextriffitt@hotmail.com
>> CC: gcc-help@gcc.gnu.org
>> Subject: Re: undefined reference to `x'
>>
>> Alex Triffitt wrote:
>>> I am trying to compiled a rather complicated program. And I am constantly getting the error:
>>> "undefined reference to `<x>'" where x is a function in a class. For example I have the file vizManager.cpp which has at the very top the statment #include "drawWindow.h". Within vizManager.cpp there is a call to create a drawWindow object through the line "drawWindow(this)". The vizManager.cpp file compiles perfectly fine but when it comes to linking with the line:
>>>
>>> g++ -g -o iNSpect configFile.o eventBuilder.o vizNodeList.o vizNode.o vizLine.o iNSpect.o vizProperties.o simWindow.o toolkitWindow.o vizManager.o nodeStats.o -pthread -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lgthread-2.0 -lglib-2.0   -Wl,--export-dynamic -lgtkglext-x11-1.0 -lgdkglext-x11-1.0 -lGLU -lGL -lgtk-x11-2.0 -lpangox-1.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0
>>>
>>> I get the following error;
>>>
>>> vizManager.o: In function `~vizManager':/home/triff/inspect-triff-beta/src/vizManager.cpp:99: undefined reference to `drawWindow::~drawWindow()'
>>> :/home/triff/inspect-triff-beta/src/vizManager.cpp:99: undefined reference to `drawWindow::~drawWindow()'
>>> vizManager.o: In function `vizManager':/home/triff/inspect-triff-beta/src/vizManager.cpp:51: undefined reference to `drawWindow::drawWindow(vizManager*)'
>>> :/home/triff/inspect-triff-beta/src/vizManager.cpp:84: undefined reference to `drawWindow::~drawWindow()'
>>> :/home/triff/inspect-triff-beta/src/vizManager.cpp:51: undefined reference to `drawWindow::drawWindow(vizManager*)'
>>> :/home/triff/inspect-triff-beta/src/vizManager.cpp:84: undefined reference to `drawWindow::~drawWindow()'
>>>
>>> The only way I have found around this is by adding the following lines near the top of vizManager.cpp:
>>>
>>> drawWindow::drawWindow(vizManager*)
>>> {
>>> }
>>> drawWindow::~drawWindow()
>>> {
>>> }
>>>
>>> This I don't think actually fixes the problem because then these functions are called do nothing and therefore cause a lot of errors.
>>>
>>> Does anyone know what is going wrong? Is this a linking problem? Or a library problem? or something totally different. I suspect this is something to do with the fact I am trying to compile using GCC version 4.1.0 when the program was orginally written for an earlier version.
>> How are the constructors and destructor for the drawWindow class
>> declared and defined?
>>
>> My guess is that you only have these declared in the class,
>> without providing bodies for the member functions.
>>
>>
>>
>> -- 
>> Michael Eager	 eager@eagercon.com
>> 1960 Park Blvd., Palo Alto, CA 94306  650-325-8077
> 


-- 
Michael Eager	 eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: undefined reference to `x'
  2006-08-03  9:04 Alex Triffitt
@ 2006-08-04 10:34 ` Michael Eager
  0 siblings, 0 replies; 8+ messages in thread
From: Michael Eager @ 2006-08-04 10:34 UTC (permalink / raw)
  To: Alex Triffitt; +Cc: gcc-help

Alex Triffitt wrote:
> Hi guys,
> Cheers for all your help. I've tried adding "drawWindow.o" to the linker line but then I get a further similar error, which requires more and more *.o files to be added. Because I am working with software that does compile on other machines I'm guessing this isn't the problem, feel free to correct me
> 
> A lot of the followup ask me questions which I don't really understand. I have a reasonable understanding of c++ but when it comes to someone elses code that isn't documented I'm pretty lost! Someone asked how they are declared in the class, is that how they are declared in the header file? If so the yare just declared as public functions.
> 
> Someone else asked me if the object files were contained within one of the libraries. I think part of my lack of understanding of c++ is how libraries work. If anyone could point me in the direction of a good tutorial on libraries I might be able to fathum something out.

I don't have a reference at hand, but the short answer is
that libraries are collections of object files.  There
are two types: archives (like libm.a) or shared (like
libcairo.so).  They are referenced on the command
line by -l followed by the library name, without the "lib"
or suffix:  -lm or -lcairo.  You can link with standard
system libraries (in /usr/lib) or you can create your own.
Many large programs will create private libraries as a part
of an incremental build process, then link with them to
create the final program.

When you link a program to create an executable,
you need to specify all of the object files which
contain referenced functions.  That includes your
drawWindow.o file.  You can either specify the
file on the command line, or specify a library
which contains the file.  The linker will search
libraries which you specify to find object files
which contain the functions referenced in previous
object files, for example drawWindow::~drawWindow().

The command line you give seems to reference only
system libraries, not private libraries.  One might
expect to see a reference to a private library
containing drawWindow.o (and all of the object files
it requires).  As Ingo suggested, perhaps something was
lost from the link line.


> Thankyou for all your replies, that gave me some ideas and I've spent quite some time trying out what you have said. Any other help would be really appreciated
> Alex
> 
> 
> 
> 
> 
> ----------------------------------------
>> From: ikrabbe.ask@web.de
>> To: gcc-help@gcc.gnu.org
>> Subject: Re: undefined reference to `x'
>> Date: Wed, 2 Aug 2006 22:32:12 +0200
>> CC: alextriffitt@hotmail.com
>>
>> Am Mittwoch, 2. August 2006 18:19 schrieb Alex Triffitt:
>>> [...]
>>>
>>> g++ -g -o iNSpect configFile.o eventBuilder.o vizNodeList.o vizNode.o
>>> vizLine.o iNSpect.o vizProperties.o simWindow.o toolkitWindow.o
>>> vizManager.o nodeStats.o -pthread -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0
>>> -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0
>>> -lgmodule-2.0 -ldl -lgthread-2.0 -lglib-2.0   -Wl,--export-dynamic
>>> -lgtkglext-x11-1.0 -lgdkglext-x11-1.0 -lGLU -lGL -lgtk-x11-2.0 -lpangox-1.0
>>> -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lpango-1.0
>>> -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0
>>>
>>> I get the following error;
>>>
>>> vizManager.o: In function
>>> `~vizManager':/home/triff/inspect-triff-beta/src/vizManager.cpp:99:
>>> undefined reference to `drawWindow::~drawWindow()'
>>> [...]
>> Well, you should examine where the drawWindow class is or should be defined.  
>> Most usefully it would live in file like drawWindow.cpp which then should 
>> compile into drawWindow.o and should then be added to the linker line above.
>>
>> What's about toolkitWindow.o ?  Anyway as I assume from the layout of your 
>> errors, drawWindow is a locally defined object, which should live somewhere 
>> near your code.  Or should it be in some library ?
>>
>> You may just have forgotten object file or libary.  Try to find out which.
> 


-- 
Michael Eager	 eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: undefined reference to `x'
@ 2006-08-03  9:04 Alex Triffitt
  2006-08-04 10:34 ` Michael Eager
  0 siblings, 1 reply; 8+ messages in thread
From: Alex Triffitt @ 2006-08-03  9:04 UTC (permalink / raw)
  To: gcc-help

Hi guys,
Cheers for all your help. I've tried adding "drawWindow.o" to the linker line but then I get a further similar error, which requires more and more *.o files to be added. Because I am working with software that does compile on other machines I'm guessing this isn't the problem, feel free to correct me

A lot of the followup ask me questions which I don't really understand. I have a reasonable understanding of c++ but when it comes to someone elses code that isn't documented I'm pretty lost! Someone asked how they are declared in the class, is that how they are declared in the header file? If so the yare just declared as public functions.

Someone else asked me if the object files were contained within one of the libraries. I think part of my lack of understanding of c++ is how libraries work. If anyone could point me in the direction of a good tutorial on libraries I might be able to fathum something out.

Thankyou for all your replies, that gave me some ideas and I've spent quite some time trying out what you have said. Any other help would be really appreciated
Alex





----------------------------------------
> From: ikrabbe.ask@web.de
> To: gcc-help@gcc.gnu.org
> Subject: Re: undefined reference to `x'
> Date: Wed, 2 Aug 2006 22:32:12 +0200
> CC: alextriffitt@hotmail.com
> 
> Am Mittwoch, 2. August 2006 18:19 schrieb Alex Triffitt:
> > [...]
> >
> > g++ -g -o iNSpect configFile.o eventBuilder.o vizNodeList.o vizNode.o
> > vizLine.o iNSpect.o vizProperties.o simWindow.o toolkitWindow.o
> > vizManager.o nodeStats.o -pthread -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0
> > -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0
> > -lgmodule-2.0 -ldl -lgthread-2.0 -lglib-2.0   -Wl,--export-dynamic
> > -lgtkglext-x11-1.0 -lgdkglext-x11-1.0 -lGLU -lGL -lgtk-x11-2.0 -lpangox-1.0
> > -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lpango-1.0
> > -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0
> >
> > I get the following error;
> >
> > vizManager.o: In function
> > `~vizManager':/home/triff/inspect-triff-beta/src/vizManager.cpp:99:
> > undefined reference to `drawWindow::~drawWindow()'
> > [...]
> 
> Well, you should examine where the drawWindow class is or should be defined.  
> Most usefully it would live in file like drawWindow.cpp which then should 
> compile into drawWindow.o and should then be added to the linker line above.
> 
> What's about toolkitWindow.o ?  Anyway as I assume from the layout of your 
> errors, drawWindow is a locally defined object, which should live somewhere 
> near your code.  Or should it be in some library ?
> 
> You may just have forgotten object file or libary.  Try to find out which.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: undefined reference to `x'
  2006-08-02 17:11 Alex Triffitt
  2006-08-02 17:53 ` Michael Eager
@ 2006-08-02 21:59 ` Ingo Krabbe
  1 sibling, 0 replies; 8+ messages in thread
From: Ingo Krabbe @ 2006-08-02 21:59 UTC (permalink / raw)
  To: gcc-help; +Cc: Alex Triffitt

Am Mittwoch, 2. August 2006 18:19 schrieb Alex Triffitt:
> [...]
>
> g++ -g -o iNSpect configFile.o eventBuilder.o vizNodeList.o vizNode.o
> vizLine.o iNSpect.o vizProperties.o simWindow.o toolkitWindow.o
> vizManager.o nodeStats.o -pthread -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0
> -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0
> -lgmodule-2.0 -ldl -lgthread-2.0 -lglib-2.0   -Wl,--export-dynamic
> -lgtkglext-x11-1.0 -lgdkglext-x11-1.0 -lGLU -lGL -lgtk-x11-2.0 -lpangox-1.0
> -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lpango-1.0
> -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0
>
> I get the following error;
>
> vizManager.o: In function
> `~vizManager':/home/triff/inspect-triff-beta/src/vizManager.cpp:99:
> undefined reference to `drawWindow::~drawWindow()'
> [...]

Well, you should examine where the drawWindow class is or should be defined.  
Most usefully it would live in file like drawWindow.cpp which then should 
compile into drawWindow.o and should then be added to the linker line above.

What's about toolkitWindow.o ?  Anyway as I assume from the layout of your 
errors, drawWindow is a locally defined object, which should live somewhere 
near your code.  Or should it be in some library ?

You may just have forgotten object file or libary.  Try to find out which.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: undefined reference to `x'
  2006-08-02 17:11 Alex Triffitt
@ 2006-08-02 17:53 ` Michael Eager
  2006-08-02 21:59 ` Ingo Krabbe
  1 sibling, 0 replies; 8+ messages in thread
From: Michael Eager @ 2006-08-02 17:53 UTC (permalink / raw)
  To: Alex Triffitt; +Cc: gcc-help

Alex Triffitt wrote:
> I am trying to compiled a rather complicated program. And I am constantly getting the error:
> "undefined reference to `<x>'" where x is a function in a class. For example I have the file vizManager.cpp which has at the very top the statment #include "drawWindow.h". Within vizManager.cpp there is a call to create a drawWindow object through the line "drawWindow(this)". The vizManager.cpp file compiles perfectly fine but when it comes to linking with the line:
> 
> g++ -g -o iNSpect configFile.o eventBuilder.o vizNodeList.o vizNode.o vizLine.o iNSpect.o vizProperties.o simWindow.o toolkitWindow.o vizManager.o nodeStats.o -pthread -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lgthread-2.0 -lglib-2.0   -Wl,--export-dynamic -lgtkglext-x11-1.0 -lgdkglext-x11-1.0 -lGLU -lGL -lgtk-x11-2.0 -lpangox-1.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0
> 
> I get the following error;
> 
> vizManager.o: In function `~vizManager':/home/triff/inspect-triff-beta/src/vizManager.cpp:99: undefined reference to `drawWindow::~drawWindow()'
> :/home/triff/inspect-triff-beta/src/vizManager.cpp:99: undefined reference to `drawWindow::~drawWindow()'
> vizManager.o: In function `vizManager':/home/triff/inspect-triff-beta/src/vizManager.cpp:51: undefined reference to `drawWindow::drawWindow(vizManager*)'
> :/home/triff/inspect-triff-beta/src/vizManager.cpp:84: undefined reference to `drawWindow::~drawWindow()'
> :/home/triff/inspect-triff-beta/src/vizManager.cpp:51: undefined reference to `drawWindow::drawWindow(vizManager*)'
> :/home/triff/inspect-triff-beta/src/vizManager.cpp:84: undefined reference to `drawWindow::~drawWindow()'
> 
> The only way I have found around this is by adding the following lines near the top of vizManager.cpp:
> 
> drawWindow::drawWindow(vizManager*)
> {
> }
> drawWindow::~drawWindow()
> {
> }
> 
> This I don't think actually fixes the problem because then these functions are called do nothing and therefore cause a lot of errors.
> 
> Does anyone know what is going wrong? Is this a linking problem? Or a library problem? or something totally different. I suspect this is something to do with the fact I am trying to compile using GCC version 4.1.0 when the program was orginally written for an earlier version.

How are the constructors and destructor for the drawWindow class
declared and defined?

My guess is that you only have these declared in the class,
without providing bodies for the member functions.



-- 
Michael Eager	 eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077

^ permalink raw reply	[flat|nested] 8+ messages in thread

* undefined reference to `x'
@ 2006-08-02 17:11 Alex Triffitt
  2006-08-02 17:53 ` Michael Eager
  2006-08-02 21:59 ` Ingo Krabbe
  0 siblings, 2 replies; 8+ messages in thread
From: Alex Triffitt @ 2006-08-02 17:11 UTC (permalink / raw)
  To: gcc-help

I am trying to compiled a rather complicated program. And I am constantly getting the error:
"undefined reference to `<x>'" where x is a function in a class. For example I have the file vizManager.cpp which has at the very top the statment #include "drawWindow.h". Within vizManager.cpp there is a call to create a drawWindow object through the line "drawWindow(this)". The vizManager.cpp file compiles perfectly fine but when it comes to linking with the line:

g++ -g -o iNSpect configFile.o eventBuilder.o vizNodeList.o vizNode.o vizLine.o iNSpect.o vizProperties.o simWindow.o toolkitWindow.o vizManager.o nodeStats.o -pthread -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lgthread-2.0 -lglib-2.0   -Wl,--export-dynamic -lgtkglext-x11-1.0 -lgdkglext-x11-1.0 -lGLU -lGL -lgtk-x11-2.0 -lpangox-1.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0

I get the following error;

vizManager.o: In function `~vizManager':/home/triff/inspect-triff-beta/src/vizManager.cpp:99: undefined reference to `drawWindow::~drawWindow()'
:/home/triff/inspect-triff-beta/src/vizManager.cpp:99: undefined reference to `drawWindow::~drawWindow()'
vizManager.o: In function `vizManager':/home/triff/inspect-triff-beta/src/vizManager.cpp:51: undefined reference to `drawWindow::drawWindow(vizManager*)'
:/home/triff/inspect-triff-beta/src/vizManager.cpp:84: undefined reference to `drawWindow::~drawWindow()'
:/home/triff/inspect-triff-beta/src/vizManager.cpp:51: undefined reference to `drawWindow::drawWindow(vizManager*)'
:/home/triff/inspect-triff-beta/src/vizManager.cpp:84: undefined reference to `drawWindow::~drawWindow()'

The only way I have found around this is by adding the following lines near the top of vizManager.cpp:

drawWindow::drawWindow(vizManager*)
{
}
drawWindow::~drawWindow()
{
}

This I don't think actually fixes the problem because then these functions are called do nothing and therefore cause a lot of errors.

Does anyone know what is going wrong? Is this a linking problem? Or a library problem? or something totally different. I suspect this is something to do with the fact I am trying to compile using GCC version 4.1.0 when the program was orginally written for an earlier version.

I would be very grateful for any help
Regards
Alex

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-08-04  1:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-02 18:28 undefined reference to `x' Alex Triffitt
2006-08-02 20:30 ` Tony Wetmore
2006-08-02 20:32 ` Michael Eager
  -- strict thread matches above, loose matches on Subject: below --
2006-08-03  9:04 Alex Triffitt
2006-08-04 10:34 ` Michael Eager
2006-08-02 17:11 Alex Triffitt
2006-08-02 17:53 ` Michael Eager
2006-08-02 21:59 ` Ingo Krabbe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).