I am trying to implement a connection pool. Compiling works but ld is showing errors. Why the linker showing the error.
In Connecter.h
class Connecter
{
private:
Connecter();
~Connecter();
static MYSQL_POOL::ConnectionPool * pool;
public:
static sql::Connection *getCon();
static void returnCon(sql::Connection *con);
};
In Connecter.cpp
Connecter::Connecter() {
pool = new MYSQL_POOL::ConnectionPool("localhost", "root", "pass");
pool->setSchema("webservice");
pool->initialize(10);
}
Connecter::~Connecter() {
pool->release();
}
sql::Connection * Connecter::getCon() {
return pool->getConnection();
}
void Connecter::returnCon(sql::Connection *con) {
pool->closeConnection(con);
}
I get am getting this error
/usr/bin/ld: /tmp/ccTlL8Sv.o: in function `Connecter::Connecter()':
Connecter.cpp:(.text+0xb8): undefined reference to `Connecter::pool'
/usr/bin/ld: Connecter.cpp:(.text+0xe6): undefined reference to `Connecter::pool'
/usr/bin/ld: Connecter.cpp:(.text+0x130): undefined reference to `Connecter::pool'
/usr/bin/ld: /tmp/ccTlL8Sv.o: in function `Connecter::~Connecter()':
Connecter.cpp:(.text+0x19b): undefined reference to `Connecter::pool'
/usr/bin/ld: /tmp/ccTlL8Sv.o: in function `Connecter::getCon()':
Connecter.cpp:(.text+0x1b7): undefined reference to `Connecter::pool'
/usr/bin/ld: /tmp/ccTlL8Sv.o:Connecter.cpp:(.text+0x1ca): more undefined references to `Connecter::pool' follow
collect2: error: ld returned 1 exit status
make: *** [Makefile:16: all] Error 1
I cant figure out what the error is. I have included the Connecter.h in Connecter.cpp. please help me