本文介绍了部署qt mysql应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了使用Qt + MySQL的应用程序.

I have developed an application that uses Qt + MySQL.

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

我已经成功编译了mysql驱动程序,我的应用程序正常运行,一切都很好.现在,我正在尝试部署应用程序,并与之一起分发所有需要的DLL.

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

现在要对其进行测试,我将C:\Qt文件夹重命名为其他名称(即C:\Qthidden).我运行了我的应用程序,但是启动该应用程序后,它无法连接到数据库(我正在运行MySQL服务器的程序所在的同一台机器上对其进行测试).

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).

我也曾尝试放入qsqlmysql.dll,但似乎没有任何改变.

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

我目前正在使用Qt 5.3和MySQL 5.5.

I'm currently using Qt 5.3 and MySQL 5.5.

有什么想法吗?谢谢您的时间.

Any ideas? Thank you for your time.

connection.lastError().text();报告驱动程序未加载".我想念什么?

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

推荐答案

您应将qsqlmysql.dll放在可执行文件旁边的名为sqldrivers的目录中.

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

这篇关于部署qt mysql应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 02:33