I can't compile Qt project with embedded MySql in VS 2010
-
Hello.
Windows XP SP3 x32
Visual Studio 2010
Project name: Peregrinans
MySql version: 5.5.25I have compiled embedded MySql driver and copied to C:\Qt\v4.8.5vs\plugins\sqldrivers four files:
qsqlmysql4.dll
qsqlmysql4.lib
qsqlmysqld4.dll
qsqlmysqld4.libIn project property I have added
Additional Library Directories - > where headers MySql files
Additional Dependencies - > libmysqld.lib@
...
#include <QtSQL>
#include "QMYSQLDriver"
...
void Peregrinans::dbInit(){
try{QSqlDatabase mydb; MYSQL *mysql;
static char *server_options[]={"mysql_test",
//"--defaults-file=.\my.ini",
"--basedir=.\db",
"--datadir=.\db\data",
"--default-character-set=utf8",
NULL};
int num_elements = (sizeof(server_options) / sizeof(char *)) - 1;static char *server_groups[] = { "test_MySQL_Embedded", "embedded", "server", NULL };
mysql_library_init(num_elements,server_options,server_groups);
mysql=mysql_init(NULL);
mysql_options(mysql,MYSQL_READ_DEFAULT_GROUP,"embedded");
mysql_options(mysql,MYSQL_OPT_USE_EMBEDDED_CONNECTION,NULL);
mysql_real_connect(mysql,NULL,NULL,NULL,"test",0,NULL,0);QMYSQLDriver *drv = new QMYSQLDriver(mysql);
mydb=QSqlDatabase::addDatabase(drv,"conn1");
mydb.setDatabaseName("test");if (!mydb.open()){
doAlert("Open DB is fail.");
return;
}else{
doAlert("DB is opened.");
return;
}
}catch(int e){
doAlert("DB no inited.");
}
}
...@During compile project I receive next errors:
@
Error 1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QMYSQLDriver::QMYSQLDriver(struct st_mysql *,class QObject *)" (_imp??0QMYSQLDriver@@QAE@PAUst_mysql@@PAVQObject@@@Z) referenced in function "private: void __thiscall Peregrinans::dbInit(void)" (?dbInit@Peregrinans@@AAEXXZ) E:\a_projects\projects\CPP\VS2010\WINXP\Qt4.8\Peregrinans\Peregrinans\Peregrinans.obj Peregrinans
Error 2 error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall QMYSQLDriver::metaObject(void)const " (?metaObject@QMYSQLDriver@@UBEPBUQMetaObject@@XZ) E:\a_projects\projects\CPP\VS2010\WINXP\Qt4.8\Peregrinans\Peregrinans\Peregrinans.obj Peregrinans
Error 3 error LNK2001: unresolved external symbol "public: virtual void * __thiscall QMYSQLDriver::qt_metacast(char const *)" (?qt_metacast@QMYSQLDriver@@UAEPAXPBD@Z) E:\a_projects\projects\CPP\VS2010\WINXP\Qt4.8\Peregrinans\Peregrinans\Peregrinans.obj Peregrinans
.........etc
@What am I doing wrong?