PDA

View Full Version : Building MySql driver



mentalmushroom
5th January 2014, 08:01
Hello. I am trying to build a MySQL driver on my Windows 8 x64 machine with Visual Studio 2008 the following way:
1) From visual studio command prompt I cd to QTDIR\src\plugins\sqldrivers\mysql
2) Edited mysql.pro to include paths to mysql.h and libmysql.lib:



TARGET = qsqlmysql

# the following two lines were added
INCLUDEPATH += "C:/Program Files/MySQL/MySQL Server 5.6/include"
LIBS += "C:/Program Files/MySQL/MySQL Server 5.6/lib/libmysql.lib"

SOURCES = main.cpp

include(../../../sql/drivers/mysql/qsql_mysql.pri)

include(../qsqldriverbase.pri)



3) run qmake
4) run nmake

On the last step I get 50 unresolved externals and I have no idea what I am doing wrong:


"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\nmake.exe" -f Makefile.Debug
C:\Qt\4.8.5\bin\moc.exe -DUNICODE -DWIN32 -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_DLL -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I"c:\Qt\4.8.5\include\QtCore" -I"c:\Qt\4.8.5\include\QtSql" -I"c:\Qt\4.8.5\include" -I"c:\Program Files\MySQL\MySQL Server 5.6\include" -I"c:\Qt\4.8.5\include\ActiveQt" -I"debug" -I"c:\Qt\4.8.5\mkspecs\default" -D_MSC_VER=1500 -DWIN32 ..\..\..\sql\drivers\mysql\qsql_mysql.cpp -o debug\qsql_mysql.moc
C:\Qt\4.8.5\bin\moc.exe -DUNICODE -DWIN32 -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_DLL -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I"c:\Qt\4.8.5\include\QtCore" -I"c:\Qt\4.8.5\include\QtSql" -I"c:\Qt\4.8.5\include" -I"c:\Program Files\MySQL\MySQL Server 5.6\include" -I"c:\Qt\4.8.5\include\ActiveQt" -I"debug" -I"c:\Qt\4.8.5\mkspecs\default" -D_MSC_VER=1500 -DWIN32 ..\..\..\sql\drivers\mysql\qsql_mysql.h -o debug\moc_qsql_mysql.cpp
rc -D_DEBUG -DUNICODE -DWIN32 -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_DLL -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -fo debug\qsqlmysqld_resource.res qsqlmysqld_resource.rc
Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1

Copyright (C) Microsoft Corporation. All rights reserved.


cl -c -nologo -Zm200 -Zc:wchar_t- -Zi -MDd -GR -EHsc -W3 -w34100 -w34189 -DUNICODE -DWIN32 -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_DLL -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I"c:\Qt\4.8.5\include\QtCore" -I"c:\Qt\4.8.5\include\QtSql" -I"c:\Qt\4.8.5\include" -I"c:\Program Files\MySQL\MySQL Server 5.6\include" -I"c:\Qt\4.8.5\include\ActiveQt" -I"debug" -I"c:\Qt\4.8.5\mkspecs\default" -Fodebug\ @C:\Users\LANAME~1\AppData\Local\Temp\nm3AF2.tmp
main.cpp
cl -c -nologo -Zm200 -Zc:wchar_t- -Zi -MDd -GR -EHsc -W3 -w34100 -w34189 -DUNICODE -DWIN32 -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_DLL -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I"c:\Qt\4.8.5\include\QtCore" -I"c:\Qt\4.8.5\include\QtSql" -I"c:\Qt\4.8.5\include" -I"c:\Program Files\MySQL\MySQL Server 5.6\include" -I"c:\Qt\4.8.5\include\ActiveQt" -I"debug" -I"c:\Qt\4.8.5\mkspecs\default" -Fodebug\ @C:\Users\LANAME~1\AppData\Local\Temp\nm432D.tmp
qsql_mysql.cpp
cl -c -nologo -Zm200 -Zc:wchar_t- -Zi -MDd -GR -EHsc -W3 -w34100 -w34189 -DUNICODE -DWIN32 -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_DLL -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I"c:\Qt\4.8.5\include\QtCore" -I"c:\Qt\4.8.5\include\QtSql" -I"c:\Qt\4.8.5\include" -I"c:\Program Files\MySQL\MySQL Server 5.6\include" -I"c:\Qt\4.8.5\include\ActiveQt" -I"debug" -I"c:\Qt\4.8.5\mkspecs\default" -Fodebug\ @C:\Users\LANAME~1\AppData\Local\Temp\nm4DC9.tmp
moc_qsql_mysql.cpp
link /LIBPATH:"c:\Qt\4.8.5\lib" /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /DLL /MANIFEST /MANIFESTFILE:"debug\qsqlmysqld.intermediate.manifest" /VERSION:4.85 /OUT:debug\qsqlmysqld4.dll @C:\Users\LANAME~1\AppData\Local\Temp\nm570D.tmp
Creating library debug\qsqlmysqld4.lib and object debug\qsqlmysqld4.exp
qsql_mysql.obj : error LNK2019: unresolved external symbol _mysql_fetch_field@4 referenced in function "public: bool __thiscall QMYSQLResultPrivate::bindInValues(void)" (?bindInValues@QMYSQLResultPrivate@@QAE_NXZ)
qsql_mysql.obj : error LNK2019: unresolved external symbol _mysql_num_fields@4 referenced in function "public: bool __thiscall QMYSQLResultPrivate::bindInValues(void)" (?bindInValues@QMYSQLResultPrivate@@QAE_NXZ)
qsql_mysql.obj : error LNK2019: unresolved external symbol _mysql_stmt_result_metadata@4 referenced in function "public: bool __thiscall QMYSQLResultPrivate::bindInValues(void)" (?bindInValues@QMYSQLResultPrivate@@QAE_NXZ)
qsql_mysql.obj : error LNK2019: unresolved external symbol _mysql_stmt_close@4 referenced in function "protected: void __thiscall QMYSQLResult::cleanup(void)" (?cleanup@QMYSQLResult@@IAEXXZ)
qsql_mysql.obj : error LNK2019: unresolved external symbol _mysql_store_result@4 referenced in function "protected: void __thiscall QMYSQLResult::cleanup(void)" (?cleanup@QMYSQLResult@@IAEXXZ)
qsql_mysql.obj : error LNK2019: unresolved external symbol _mysql_next_result@4 referenced in function "protected: void __thiscall QMYSQLResult::cleanup(void)" (?cleanup@QMYSQLResult@@IAEXXZ)
qsql_mysql.obj : error LNK2019: unresolved external symbol _mysql_free_result@4 referenced in function "protected: void __thiscall QMYSQLResult::cleanup(void)" (?cleanup@QMYSQLResult@@IAEXXZ)
qsql_mysql.obj : error LNK2019: unresolved external symbol _mysql_fetch_row@4 referenced in function "protected: virtual bool __thiscall QMYSQLResult::fetch(int)" (?fetch@QMYSQLResult@@MAE_NH@Z)
qsql_mysql.obj : error LNK2019: unresolved external symbol _mysql_data_seek@12 referenced in function "protected: virtual bool __thiscall QMYSQLResult::fetch(int)" (?fetch@QMYSQLResult@@MAE_NH@Z)
qsql_mysql.obj : error LNK2019: unresolved external symbol _mysql_stmt_fetch@4 referenced in function "protected: virtual bool __thiscall QMYSQLResult::fetch(int)" (?fetch@QMYSQLResult@@MAE_NH@Z)
qsql_mysql.obj : error LNK2019: unresolved external symbol _mysql_stmt_data_seek@12 referenced in function "protected: virtual bool __thiscall QMYSQLResult::fetch(int)" (?fetch@QMYSQLResult@@MAE_NH@Z)
qsql_mysql.obj : error LNK2019: unresolved external symbol _mysql_stmt_errno@4 referenced in function "class QSqlError __cdecl qMakeStmtError(class QString const &,enum QSqlError::ErrorType,struct st_mysql_stmt *)" (?qMakeStmtError@@YA?AVQSqlError@@ABVQString@@W4Er rorType@1@PAUst_mysql_stmt@@@Z)
qsql_mysql.obj : error LNK2019: unresolved external symbol _mysql_stmt_error@4 referenced in function "class QSqlError __cdecl qMakeStmtError(class QString const &,enum QSqlError::ErrorType,struct st_mysql_stmt *)" (?qMakeStmtError@@YA?AVQSqlError@@ABVQString@@W4Er rorType@1@PAUst_mysql_stmt@@@Z)
qsql_mysql.obj : error LNK2019: unresolved external symbol _mysql_num_rows@4 referenced in function "protected: virtual bool __thiscall QMYSQLResult::fetchLast(void)" (?fetchLast@QMYSQLResult@@MAE_NXZ)
qsql_mysql.obj : error LNK2019: unresolved external symbol _mysql_stmt_num_rows@4 referenced in function "protected: virtual bool __thiscall QMYSQLResult::fetchLast(void)" (?fetchLast@QMYSQLResult@@MAE_NXZ)
qsql_mysql.obj : error LNK2019: unresolved external symbol _mysql_fetch_lengths@4 referenced in function "protected: virtual class QVariant __thiscall QMYSQLResult::data(int)" (?data@QMYSQLResult@@MAE?AVQVariant@@H@Z)
qsql_mysql.obj : error LNK2019: unresolved external symbol _mysql_fetch_field_direct@8 referenced in function "protected: virtual bool __thiscall QMYSQLResult::reset(class QString const &)" (?reset@QMYSQLResult@@MAE_NABVQString@@@Z)
qsql_mysql.obj : error LNK2019: unresolved external symbol _mysql_affected_rows@4 referenced in function "protected: virtual bool __thiscall QMYSQLResult::reset(class QString const &)" (?reset@QMYSQLResult@@MAE_NABVQString@@@Z)
...
qsql_mysql.obj : error LNK2019: unresolved external symbol _mysql_thread_end@0 referenced in function "public: virtual void __thiscall QMYSQLDriver::close(void)" (?close@QMYSQLDriver@@UAEXXZ)
qsql_mysql.obj : error LNK2019: unresolved external symbol _mysql_list_tables@8 referenced in function "public: virtual class QStringList __thiscall QMYSQLDriver::tables(enum QSql::TableType)const " (?tables@QMYSQLDriver@@UBE?AVQStringList@@W4TableT ype@QSql@@@Z)
qsql_mysql.obj : error LNK2019: unresolved external symbol _mysql_list_fields@12 referenced in function "public: virtual class QSqlRecord __thiscall QMYSQLDriver::record(class QString const &)const " (?record@QMYSQLDriver@@UBE?AVQSqlRecord@@ABVQStrin g@@@Z)
qsql_mysql.obj : error LNK2019: unresolved external symbol _mysql_query@8 referenced in function "protected: virtual bool __thiscall QMYSQLDriver::beginTransaction(void)" (?beginTransaction@QMYSQLDriver@@MAE_NXZ)
qsql_mysql.obj : error LNK2019: unresolved external symbol _mysql_real_escape_string@16 referenced in function "public: virtual class QString __thiscall QMYSQLDriver::formatValue(class QSqlField const &,bool)const " (?formatValue@QMYSQLDriver@@UBE?AVQString@@ABVQSql Field@@_N@Z)
debug\qsqlmysqld4.dll : fatal error LNK1120: 50 unresolved externals


I use Qt 4.8.5. I thought, maybe MySql driver sources shipped with that version are not compatible with the latest MySql lib (5.6.15)? Could somebody help me out?

mentalmushroom
5th January 2014, 11:45
Fixed the issue myself. It looks like MySql 5.6 installer (not sure about previous versions) being itself 32 bit installs only 64 bit version of a client library for C development, therefore the driver could not link properly to libmysql.lib. In order to fix the issue, download the 32 bit version of Connector/C (libmysqlclient) and use those .lib and .dll files. Worked both with Qt 4.8.5 + Visual Studio 2008 and Qt 5.2.0 + Visual Studio 2012.