Qt Compiled Oracle OCI driver

Source: Internet
Author: User

Oracle is often used in the work, but by default Qt is only SQLite and ODBC driver, the network has the corresponding driver installation introduction, its own experiment is feasible:

QT Environment: QT 5.0.2/mingw4.7.2/win7 32bit

Open qt Command Prompt and execute the following commands to compile the Oracle driver:

Set include=%include%; C:\oracle\product\10.2.0\db_1\OCI\include; C:\Qt\Qt5.0.2\Tools\MinGW\include
Set lib=%lib%; C:\oracle\product\10.2.0\db_1\OCI\lib\MSVC
CD C:\Qt\Qt5.0.2\5.0.2\Src\qtbase\src\plugins\sqldrivers\oci
Qmake Oci.pro
Mingw32-make

Where C:\oracle\product\10.2.0\db_1\OCI\include is the directory where Oracle OCI drives source code, D:/qt/mingw/include is the location of the compilation environment.

After executing the above statement, you will generate LIBQSQLOCI.A, LIBQSQLOCID.A, Qsqloci.dll, qsqlocid.dll four files, copy them to C:\Qt\Qt5.0.2\5.0.2\mingw47_32\ In the Plugins\sqldrivers directory.
Test in the program:

#include <QCoreApplication>
#include <QtSql/QSqlDatabase>
#include <QDebug>
#include <QStringList>
int main (int argc, char *argv[])
{
Qcoreapplication A (argc, argv);
Qdebug () << "Available drivers:";
Qstringlist drivers = qsqldatabase::d rivers ();
foreach (QString driver, drivers)
Qdebug () << "/t" << driver;
return A.exec ();
}

You can see the list of drivers that are now available:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.