Qt static with MYSQL



  • Hello I am trying to build qt staticaly in Windows using nmake. Entering in Visual Studio command prompt I am typing the following commands:

    vcvarsall.bat x86
    then
    switching to qt open source for windows msvc folder and type:
    configure -L C:\mysql\lib -I C:\mysql\include -release -nomake examples -nomake demos -no-exceptions -no-stl -no-rtti -no-qt3support -no-scripttools -no-openssl -no-opengl -no-webkit -no-phonon -no-style-motif -no-style-cde -no-style-cleanlooks -no-style-plastique -static -qt-sql-mysql -platform win32-msvc2008

    My mysql version is 5.5 fresh downloaded from site and installed only the sources without the server.

    After configure is made I am typing nmake and the compiling starts.

    After some time I get unresolved externals. All pointing to myslq.

    My target is to have only one executable file with my application that includes all qt and mysql. What am I doing wrong?

    This is a part of error:

    Creating library ........\bin\assistant.lib and object ........\bin\ass
    istant.exp
    QtSql.lib(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)
    QtSql.lib(qsql_mysql.obj) : error LNK2019: unresolved external symbol _mysql_stm
    t_num_rows@4 referenced in function "protected: virtual bool __thiscall QMYSQLRe
    sult::fetchLast(void)" (?fetchLast@QMYSQLResult@@MAE_NXZ)
    QtSql.lib(qsql_mysql.obj) : error LNK2019: unresolved external symbol _mysql_clo
    se@4 referenced in function "public: virtual void __thiscall QMYSQLDriver::close
    (void)" (?close@QMYSQLDriver@@UAEXXZ)
    QtSql.lib(qsql_mysql.obj) : error LNK2019: unresolved external symbol _mysql_thr
    ead_end@0 referenced in function "public: virtual void __thiscall QMYSQLDriver::
    close(void)" (?close@QMYSQLDriver@@UAEXXZ)
    QtSql.lib(qsql_mysql.obj) : error LNK2019: unresolved external symbol _mysql_cha
    racter_set_name@4 referenced in function "class QTextCodec * __cdecl codec(struc
    t st_mysql *)" (?codec@@YAPAVQTextCodec@@PAUst_mysql@@@Z)
    QtSql.lib(qsql_mysql.obj) : error LNK2019: unresolved external symbol _mysql_fet
    ch_lengths@4 referenced in function "protected: virtual class QVariant __thiscal
    l QMYSQLResult::data(int)" (?data@QMYSQLResult@@MAE?AVQVariant@@H@Z)
    QtSql.lib(qsql_mysql.obj) : error LNK2019: unresolved external symbol _mysql_ins
    ert_id@4 referenced in function "protected: virtual class QVariant __thiscall QM
    YSQLResult::lastInsertId(void)const " (?lastInsertId@QMYSQLResult@@MBE?AVQVarian
    t@@XZ)



  • First check the MySQL client library documentation. Is it possible to link with it statically?



  • There are 3 files in lib folder of mysql. libmysql.dll, libmysql.lib and mysqlclient.lib. I quess the last is for static build. The problem is that I have tryed to use explicit mysqlcliend.lib but getting other or the same link errors. I am sure that I am doing something wrong.
    Another question is regarding the qt static build. I am thinking to build only qt static and the try to link mysql lib. As far as I have read on the web you cannot add static link to mysql once you have build qt without that libs...



  • Another problem could be regarding the /MD and /MT switch... Right now I am trying to build qt using /MT on release



  • I have compiled qt in different ways entire night with no success. I guess I must use all qt army of dll for my project :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.