I created a Windows Qt C++ application that performs some SQL queries. This application compiled and runs correctly on my development machine.
I have these directories in my PATH environment variable:
C:\oracle\product\10.2.0\db_1\bin
C:\instantclient_11_2
C:\QtSDK\mingw\bin
C:\Qt\4.7.4\bin
I would like to distribute my application as a standalone to other computers so I have included these .dll files with the distribution:
QtCore4.dll
QtGui4.dll
QtSql4.dll
qsqloci4.dll
mingwm10.dll
libgcc_s_dw2-1.dll
This is how my QSqlDatabase is setup in my code:
QSqlDatabase db = QSqlDatabase::addDatabase("QOCI");
db.setHostName(hostname);
db.setPort(port);
db.setDatabaseName(sid);
db.setUserName(username);
db.setPassword(password);
bool ok = db.open();
if (ok) {
//stuff
} else {
QString dbErr = db.lastError().databaseText();
QString drErr = db.lastError().driverText();
return this->messageBox("SQL Query Failed:\n" + dbErr + "\n" + drErr);
}
When I run this application on a computer that is not my development machine, dbErr and drErr are set to “Driver not loaded”. What other .dll files do I need in order to get this to run correctly?
Edit:
Do I need oci.dll from C:\oracle\product\10.2.0\db_1\bin?
What about oci.dll from C:\instantclient_11_2?
I tried adding both of those files to my executable’s directory, but I still get the same error. Do I need both of those .dll files somehow?
You need to create a folder call
sqldriversin the directory containing your exe. Put all the SQL driver DLLs you are using in there (qsqloci4.dll).See How to Create Qt Plugins – Locating Plugins for more information on using Qt plugins and how Qt finds them.