linker error, undefined reference?
I'm getting some strange linker errors in my C++ project:
1 2 3 4
|
obj\Debug\main.o||In function `_ZSt19__iterator_categoryIPSsENSt15iterator_traitsIT_E17iterator_categoryERKS2_':|
)]+0xbf)||undefined reference to `Command::PVT'|
)]+0x17)||undefined reference to `Command::PVT'|
||=== Build finished: 2 errors, 0 warnings ===|
|
Full class:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <cstdarg>
#include <vector>
#include <string>
class Command {
public:
Command() {}
Command(std::string Eval) : IF(0) {
Com.push_back("test");// 0
for (unsigned int i = 0; Eval != Com.at(i); ++i) {
if (i < Com.size()) {
++IF;
} else {
break;
}
}
p_start(IF);
}
static void test() { std::cout << "test" << std::endl; }
void Init() {
PVT.push_back(test);// 0
}
void p_start(int F) {
Init();
(*PVT[F])();
}
~Command() {}
private:
int IF;
typedef void(*P2_F)(void);
static std::vector<P2_F> PVT;
std::vector<std::string> Com;
};
|
this has been baffling me for over an hour, it just doesn't make any sense at all. Anybody know whats up?
Edit: by the way, I'm using Code::Blocks compiler on windows 7
Last edited on
undefined reference to `Command::PVT' |
In your class you have below statement.
static std::vector<P2_F> PVT;
You need to define it in your .cpp file. E.g
std::vector<P2_F> Command::PVT;
Topic archived. No new replies allowed.