hello and good afternoon...
i try to create a dll file in c++ and link with mysql api
i already link mysql lib and header to visual studio
when i try to build it..
i got these error messages :
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol _mysql_init@4 referenced in function "public: void __thiscall MySQLConnector::openConnection(void)" (?openConnection@MySQLConnector@@QAEXXZ) MySQLConnectorDLL C:\Users\user\Desktop\MySQLConnectorDLL\MySQLConnectorDLL\MySQLConnector.obj 1
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol _mysql_real_connect@32 referenced in function "public: void __thiscall MySQLConnector::openConnection(void)" (?openConnection@MySQLConnector@@QAEXXZ) MySQLConnectorDLL C:\Users\user\Desktop\MySQLConnectorDLL\MySQLConnectorDLL\MySQLConnector.obj 1
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol _mysql_close@4 referenced in function "public: void __thiscall MySQLConnector::closeConnection(void)" (?closeConnection@MySQLConnector@@QAEXXZ) MySQLConnectorDLL C:\Users\user\Desktop\MySQLConnectorDLL\MySQLConnectorDLL\MySQLConnector.obj 1
Severity Code Description Project File Line Suppression State
Error LNK1120 3 unresolved externals MySQLConnectorDLL C:\Users\user\Desktop\MySQLConnectorDLL\Debug\MySQLConnectorDLL.dll 1
What I have tried:
what i have did in my code is :
in my header file :
#pragma once
#include "mysql.h"
class MySQLConnector {
public :
void openConnection();
void closeConnection();
bool connectionStatus();
private :
bool _connectionStatus;
MYSQL *_con, *_connectionString;
};
in my cpp file
#pragma once
#include "C:\BookScanner\extension\cpp files\header\CppMySQL.h"
#include <mysql.h>
void MySQLConnector::openConnection(){
_con = mysql_init(NULL);
_connectionString = mysql_real_connect(_con, "localhost", "root", "", "bookbardatabase", 3306, NULL, 0);
_connectionStatus = _connectionString ? true: false;
}
void MySQLConnector::closeConnection()
{
mysql_close(_con);
}
bool MySQLConnector::connectionStatus()
{
return _connectionStatus;
}
and this is my dll file, i failed to build it
#include "C:\BookScanner\extension\cpp files\header\CppMySQL.h"
#include "C:\BookScanner\extension\cpp files\cpp\CppMySQL.cpp"
MySQLConnector connector;
extern "C" __declspec(dllexport) void openConnection() {
connector.openConnection();
}
extern "C" __declspec(dllexport) void closeConnection() {
connector.closeConnection();
}
extern "C" __declspec(dllexport) bool connectionStatus() {
return connector.connectionStatus();
}