Hi out there!
I am currently writing a wrapper for our MySQL database in C++ - and I'm fairly new to C++
(in fact, this is my first project ^^). So please excuse any dumb-ass things ;-)
Ok, now the problem: Whenever I try to compile my program (a single class at the moment)
using my makefile, this would be the output:
$> make test2
g++ -g -O2 -Wall -I/usr/include -I/usr/include/mysql
-I/usr/local/mysql++-3.0.8/include/mysql++ -L/usr/lib64/mysql
/usr/local/mysql++-3.0.8/lib -l mysqlclient -l mysqlpp -l boost_regex test2.cpp -o test2
test2.cpp: In constructor 'Database::Database()':
test2.cpp:30: error: no matching function for call to
'mysqlpp::Connection::Connection(const char* [0u], const char* [0u], const char* [0u],
const char* [0u], unsigned int&)'
/usr/local/mysql++-3.0.8/include/mysql++/connection.h:114: note: candidates are:
mysqlpp::Connection::Connection(const mysqlpp::Connection&)
/usr/local/mysql++-3.0.8/include/mysql++/connection.h:108: note:
mysqlpp::Connection::Connection(const char*, const char*, const char*, const char*,
unsigned int)
/usr/local/mysql++-3.0.8/include/mysql++/connection.h:72: note:
mysqlpp::Connection::Connection(bool)
make: *** [test2] Fehler 1
-------------------------------------
Ok now, here's the code extract I compiled to show you the error:
#include <mysql++.h>
#include <ostream>
using namespace std;
class Database
{
const char* dbHost[];
const char* dbName[];
const char* dbUser[];
const char* dbPass[];
unsigned int dbPort;
mysqlpp::Connection dbConn;
Database();
Database(char* db, char* user, char* pass, char* host, unsigned int port);
~Database() {}
};
Database::Database()
{
*dbHost = "hostname:3306";
*dbName = "db_name";
*dbUser = "db_user";
*dbPass = "password";
dbPort = 3306;
mysqlpp::Connection dbConn(dbName, dbHost, dbUser, dbPass, dbPort);
}
Database::Database(char* db, char* user, char* pass, char* host, unsigned int port)
{
try
{
dbConn = mysqlpp::Connection(db, host, user, pass, port);
}
catch(mysqlpp::ConnectionFailed connFailedEx)
{
cerr << "Connection failed: " << connFailedEx.what() << "Error
number " << connFailedEx.errnum() << endl;
}
catch(mysqlpp::Exception ex)
{
cerr << "Fatal error during connection initialization:" << endl
<< ex.what() << endl;
}
}
------------------------------------
Do you have any suggestion why the function lookup fails to find the correct version? I am
sure the datatypes are correct - but on the other hand, this seems to be the only possible
reason....
I am really longing for your help - it is so frustrating....
Thanks in advance,
Johannes