Hey guys, I've been learning SFML and am getting an obnoxious linker error that I can't understand :/ I have a static vector in my CMoveableObject class and I'm getting unresolved external symbol errors whenever I try to access it outside of the class. My code can be found here: http://www.sfmluploads.org/index.php?page=view_file&file_id=23
Globally in your movableobject cpp file, you need to put this line:
1 2 3 4
std::vector<CMoveableObject*> CMovableObject::PAVCMoveableObject;
// did I get the name right? PAVCMoveableObject? Name it whatever you named it
// in the class
Thank you, that fixed the first of my linker errors. I am now getting this:
CMoveableObject@@2V?$vector@PAVCMoveableObject@@V?$allocator@PAVCMoveableObject@@@std@@@std@@A) already defined in main.obj
I guess it's a "multiply defined" error, so next time I have a chance I'll look around and find the second definition...
It could also be that you put that code in a header file that is included in multiple cpp files. In that case, the static declaration needs to be in only one cpp, so either put it in your class' related cpp file, or if you inline your class functions pick a cpp file and stick it there.