Qt release application don't see plugin - c++

I have a problem with release application, it is don't see psql driver if i start it by exe from explorer.
But it works perfect if i start it from visual studio...
I place these files near exe, and no result:
unins000.dat
msvcp140.dll
qsqlpsql.dll
Qt5Core.dll
Qt5Gui.dll
Qt5Network.dll
Qt5Sql.dll
vccorlib140.dll
Server.exe
unins000.exe
config.json
error:
QSqlDatabase: QPSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC ODBC3 QPSQL QPSQL7
but i compiled that plugin defore!
Whats can be wrong?

To deploy qt application with plugins you should also add plugins in same folder as application. How to deploy qt applications with plugins
You should also add platform folder near application to be able to deploy your application on computers where qt isn't available.
It's on Linux but same applies in windows. You can only add sqldrivers in plugins folder.
qt.conf file contaians:
[Paths]
Plugins=plugins
Also run Dependency Walker to find all dependent libraries.

Related

Application failed to start because it could not find or load the Qt platform plugin "xcb" in

I am using Qtcreator to build and run my program. Build is success but while running I am getting the following error
This application failed to start because it could not find or load the Qt platform plugin "xcb"
Reinstalling the application may fix this problem.
I am using Qt5.6.1-1 and creator 4.0.3 based on Qt 5.6.1
Tried by exporting path
export QT_PLUGIN_PATH=/home/SysUser/Development/Qt5.6.1-1/plugins/platforms
Still its not working
I am having Qt5.12.6 also installed but this app need Qt 5.6.1 so I renamed Qt5.12.6 folder.
Any lights will be a great help

Qt database drivers

I built qt with -plugin-sql-mysql -plugin-sql-sqlite flags. I have libqsqlmysql.a and libqsqlite.a. I use qt in my project. But my build system is not qt, I use waf.
I have the following problem when I try to run my application which establishes connection with mysql database:
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers:
QSqlDatabase: an instance of QCoreApplication is required for loading driver plugins
INFO - Failed to connect to root mysql admin
I added -lqsqlmysql to compiler options when I build the app.
Can you please explain how qt drivers work, how and when it tries to load driver. What is a qt driver (dll, lib, ....)?
I think your app is trying to load the database plugin dynamically, from a DLL. This document will help you find the appropriate location for the database driver DLL. Alternatively, you could link your app against the plugin statically, here's how.
Qt has plugins for several types of databases and these plugins are located in the following location:
$(QTDIR)/plugins/sqldrivers
First check if mysql plugin is present there. If plugin is not there then it means you didn't compile Qt properly, so you should recompile Qt with enabled MySql plugin. Otherwise probably your application doesn't load mysql plugin properly. Qt plugins are loaded dynamically during initialization of application i.e when QSqlDatabase object will be initialized. If plugin location is not set properly then none of plugins will be loaded. You can check location where your application expect to find plugins via following Qt API:
QStringList QCoreApplication::libraryPaths ()
If application doesn't point to right location you can set plugin path by calling of:
void QCoreApplication::addLibraryPath ( const QString & path )
 
Or by creation of qt.conf file in folder where your executable is placed. In this file you can configure plugins location in the following way:
[Paths]
Plugins = %pluginlocation%

Can't deploy Qt application with QMYSQL

I have an application that requires to connect to MySQL database, I am using Qt 4.7. I built the QMYSQL plugin and everything works just fine ON MY MACHINE. When I tried to test the application on another machine with the folder "sqldrivers" contains the "qsqlmysql4.dll" next to my executable. I get this error "Driver not loaded". After hours of searching the web and following the Qt documentation I came up with nothing.
Please tell me what am I missing.
Is there an actual mysql client DLL (like libmysqlclient.dll or something) that's installed on your machine, and also needs to be included with the app?

Windows, Mingw Qt Application Does Not Run On Deployed Computers

I have created a Qt application with Mingw. The application runs properly on the development computer after copying the required DLL's to the directory. However, when deploying on external computers, the application does not run at all.
Update:
In addition, the application uses Sqlite3 via QtSql.
It's quite likely you're still missing some dll.
Check the Windows event log for any errors after running the application. (Administrative Tools->Event Viewer).
Try launching the application from a command prompt window.
Try Dependency Walker.
Another thought is some missing configuration file or registry settings.
Double check against the Qt docs for deploying Windows Qt applications.

vs 2008 deployment project not working

I have a C++ console application that I want to deploy using a vs2008 setup project. When I create the setup project and add the output from my console app, the setup project detects that it needs MSVCP90.dll and MSVCR90.dll. When I build the project, those two dlls are included in the .msi file as expected.
When I download and launch the installer, everything goes as expected and the console app and the dlls are unpacked into the proper directory on the local machine.
When I try and run the app, I get the following error:
Error 1721. There is a problem with
this Windows Installer package. A
program required for this install to
complete could not be run. Contact
your support personnel or package
vendor.
I've tried compiling the app with /MT and /MD neither one works.
When I run a dependency walker against the app, it reports that it needs MSVCP90.dll and MSVCR90.dll as expected.
Finally, if I set the installer to require the Visual C++ runtime libraries, it downloads them and everything works fine.
Obviously, I would like to avoid downloading the CRT libraries.
Thanks for any help,
Jon
Check out this example on how to add the appropriate merge modules and deploy them to your target machine along with your setup.