I am running this code on Linux Mint:
#include <iostream>
#include <memory>
#include "Logger.h"
#include "Config.h"
#include "mysql_connection.h"
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
using namespace std;
int main() {
shared_ptr<Config> config = make_shared<Config>("WorldServer");
string def = "Nothing there.";
Logger::Log("Authserver Conn: " + config->GetConfigValue("LoginDatabaseInfo", def));
try {
sql::Driver *driver;
sql::Connection *con;
sql::Statement *stmt;
sql::ResultSet *res;
const string host = config->GetConfigValue("LoginDatabase.MySQL.IP", def);
const string mysqlUser = config->GetConfigValue("LoginDatabase.MySQL.IP", def);
const string mysqlPassword = config->GetConfigValue("LoginDatabase.MySQL.IP", def);
const string mysqlDatabase = config->GetConfigValue("LoginDatabase.MySQL.IP", def);
/* Create a connection */
driver = get_driver_instance();
con = driver->connect(host, mysqlUser, mysqlPassword);
/* Connect to the MySQL test database */
con->setSchema(mysqlPassword);
stmt = con->createStatement();
res = stmt->executeQuery("SELECT * FROM accounts");
while (res->next()) {
cout << "\t... MySQL replies: ";
/* Access column data by alias or column name */
cout << res->getString("warTag") << endl;
cout << "\t... MySQL says it again: ";
/* Access column data by numeric offset, 1 is the first column */
cout << res->getString(1) << endl;
}
delete res;
delete stmt;
delete con;
} catch (sql::SQLException &e) {
cout << "# ERR: SQLException in " << __FILE__;
cout << "(" << __FUNCTION__ << ") on line " << __LINE__ << endl;
cout << "# ERR: " << e.what();
cout << " (MySQL error code: " << e.getErrorCode();
cout << ", SQLState: " << e.getSQLState() << " )" << endl;
}
}
When I try to build it I receive the following error:
undefined reference to `get_driver_instance`
I also have this installed:
sudo apt-get install libmysqlcppconn-dev
What can be the cause of this problem and how can I fix it ?