I am unable to understand why my program is unable to find a private static variable within the class it is defined in. From the terse output of the linker all I can make out is that Entity.cpp calls ComponentFactory's get_map method which for some reason cannot find map within the private field of the class. Here are the affected source files, any help would be greatly appreciated.
g++ -std=c++11 Entity.hpp Entity.cpp Component.hpp ComponentFactory.hpp GridPosition.hpp main.cpp -o main
1 2 3 4 5 6 7
/tmp/ccHoJBDl.o: In function `ComponentFactory::get_map()':
Entity.cpp:(.text._ZN16ComponentFactory7get_mapEv[_ZN16ComponentFactory7get_mapEv]+0xa): undefined reference to `ComponentFactory::map'
Entity.cpp:(.text._ZN16ComponentFactory7get_mapEv[_ZN16ComponentFactory7get_mapEv]+0x2b): undefined reference to `ComponentFactory::map'
Entity.cpp:(.text._ZN16ComponentFactory7get_mapEv[_ZN16ComponentFactory7get_mapEv]+0x32): undefined reference to `ComponentFactory::map'
collect2: error: ld returned 1 exit status
Makefile:6: recipe for target 'main' failed
make: *** [main] Error 1
Thank you so much. I had seen something about having to define the variable in a separate cpp file in some stackoverflow post but then I defined it incorrectly, as static ComponentFactory::map_type* map, and dismissed that potential problem. Got it compiled and running.