Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

'undefined reference' linking error

Status
Not open for further replies.

gmarkey

Programmer
May 29, 2003
2
AU
G'day all,
I am trying to compile and link a project of mine but am stumped on a linking error. The error reads
/usr/include/g++-3/stl_vector.h:197: undefined reference to 'tracking_gui::images'

the error is repeated for stl_vector.h:320 and 322.

images is declared in the header file as
static std::vector< TG_Image *> images;

the line that uses images within tracking_gui.cpp is --
images.push_back(t);

If anyone has an idea as to what ime doing wrong ide appreciate a reply.
 
Looks like it is part of a structure. If it is, you need to declare it in the source as well. i.e.
Code:
std::vector<TG_Image*> tracking_gui::images;
 
Normally, whatever you declare is instantiated when you create an instance of the class. However, with statics, because there is one and only one instance, it is not instantiated with the class and as such needs a separate declaration.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top