This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: undefined reference to `x'


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]