Hello, This is my first usenet posting, so please be gentle. :)
I have a very odd issue with some fairly simple code I'm trying to get working. In one of my headers, I have the line: static size_t _sharkcount; and if I reference that variable through other functions and whatnot, things are fine. However, if I add a new variable in that header, immediately below that one, with the name of static size_t _supersharkcount; or really, *any* other name (tried _foo and _rippingmydamnhairout), and try to reference that one, I have linking issues. Everything compiles just fine, but in linking my object files together, I get a few of: Object.o:Object.C:(.text$_ZN10SuperSharkD0Ev[SuperShark::~SuperShark()]+0x40): undefined reference to `Object::_supersharkcount' Object.o:Object.C:(.text$_ZN10SuperSharkD0Ev[SuperShark::~SuperShark()]+0x78): undefined reference to `Object::_supersharkcount' Object.o:Object.C:(.text$_ZN10SuperSharkD1Ev[SuperShark::~SuperShark()]+0x48): undefined reference to `Object::_supersharkcount' Object.o:Object.C:(.text$_ZN10SuperSharkD1Ev[SuperShark::~SuperShark()]+0x77): more undefined references to `Object::_supersharkcount' follow collect2: ld returned 1 exit status I also get another error in a World.o file that uses a function that hits _supersharkcount. If I change my destructor (and other points in the code) to hit _sharkcount instead of _supersharkcount, then I don't get all of these undefined references. However, adding this one other static variable (which is in the protected space of my Object class) causes the linking to fail. I've been all over Google and looking through various newsgroups, and I find specific instance problems, such as getting the undefined references when compiling very specific programs, but I can't find anything that seems to relate to my problem here. I've tried compiling this with g++ 3.4.4 in Cygwin on a WinXP box, g++ 3.3.5 on a Debian box, and g++ 3.4.2 on a FreeBSD box. While the verbiage in the location within .text is different, it's all the same message, saying I have an undefined reference to Object::_supersharkcount, during the linking. The code itself compiles fine all over. I would greatly appreciate any information that could be provided to me. Thank you so much for your help. _______________________________________________ Help-gplusplus mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-gplusplus
