Deploying qt mysql application

2019-05-12 00:09发布

I have developed an application that uses Qt + MySQL.

connection = QSqlDatabase::addDatabase("QMYSQL");

I've successfully compiled the mysql drivers, my application works and everything is fine. Now I'm trying to deploy my application, distribuing along with it all the DLLs needed.

So far I have included:

platforms/qwindows.dll
icudt52.dll
icuin52.dll
icuuc52.dll
libgcc_s_dw2-1.dll
libstdc++-6.dll
libwinpthread-1.dll
Qt5Core.dll
Qt5Gui.dll
Qt5Sql.dll
Qt5Widgets.dll
libEGL.dll     // not needed but included anyway
libmysql.dll   // compiled drivers

Now to test it I rename the C:\Qt folder to something else (i.e. C:\Qthidden). I run my application but it when launched it cannot connect to the database (I'm testing it on the same machine I made the program which have the MySQL server running).

I have also tried to put in qsqlmysql.dll but it doesn't seem to change anything.

I'm currently using Qt 5.3 and MySQL 5.5.

Any ideas? Thank you for your time.

EDIT: connection.lastError().text(); reports "Driver not loaded". What am I missing?

1条回答
Rolldiameter
2楼-- · 2019-05-12 00:40

You should place qsqlmysql.dll in a directory named sqldrivers alongside the executable.

查看更多
登录 后发表回答