I started working on a language parser and came across with undefined reference while I was using std::map<std::string, std::string>
/usr/bin/ld: /home/leksoBor/Desktop/research/neuLogo/src/./rules/0000_program_base/Program.hh:106: undefined reference to `ProgramObj::envCnfgTable[abi:cxx11]'
/usr/bin/ld: /home/leksoBor/Desktop/research/neuLogo/src/./rules/0000_program_base/Program.hh:107: undefined reference to `ProgramObj::envCnfgTable[abi:cxx11]'
/usr/bin/ld: /home/leksoBor/Desktop/research/neuLogo/src/./rules/0000_program_base/Program.hh:108: undefined reference to `ProgramObj::envCnfgTable[abi:cxx11]'
/usr/bin/ld: /home/leksoBor/Desktop/research/neuLogo/src/./rules/0000_program_base/Program.hh:109: undefined reference to `ProgramObj::envCnfgTable[abi:cxx11]'
/usr/bin/ld: parser.tab.o:/home/leksoBor/Desktop/research/neuLogo/src/./rules/0000_program_base/Program.hh:113: more undefined references to `ProgramObj::envCnfgTable[abi:cxx11]' follow
This is the error message I am getting and the code is following:
static void resetEnvCnfgTable()
{
envCnfgTable.insert(std::pair<std::string,std::string>("version", "0.0") );
envCnfgTable.insert(std::pair<std::string,std::string>("description", "no description"));
envCnfgTable.insert(std::pair<std::string,std::string>("real-type", "64-bit"));
envCnfgTable.insert(std::pair<std::string,std::string>("whole-type", "32-bit"));
envCnfgTable.insert(std::pair<std::string,std::string>("random-type", "mersenne"));
};
static void printEnvCnfgTable()
{
for(std::map<std::string, std::string>::iterator it = envCnfgTable.begin(); it != envCnfgTable.end(); it ++)
{
std::cout << it -> first << " " << it -> second << '\n';
}
};
static std::map<std::string, std::string> envCnfgTable;
I use:
clang++ -g -c -Wall -std=c++11 -o ../../parts/grammar/Program.o Program.cc
Any suggestions? I saw some threads similiar but could not resolve the problem.