So here is how to do it:
Preliminary remarks:
I had QtSDK / QtCreator / Qt 4.8.1 32 lib, so I also had a QtSources folder in my directory system, as well as “Qt 4.8.1 for the desktop (MinGW)” - a command line prepared for use with Qt, Also, an Oracle 32 database was installed with the folder C: \ Oracle \ with the "include" and "lib" folders inside. The "include" has .h, such as oci.h, and the "lib" has .dlls and .lib, such as oci.dll, all of which are necessary for compilation. Following the Qt Project documentation, I add "c: \ oracle \ bin" to the PATH environment variable (Computer Properties → Advanced System Settings → Advance Tab → Environment Variables → System Variables).
First try:
The default code (actually one for debug lib) for compilation, as shown on the Qt Project website, adjusted to MinGW, is as follows:
set INCLUDE=%INCLUDE%;c:\oracle\oci\include set LIB=%LIB%;c:\oracle\oci\lib\msvc cd %QTDIR%\src\plugins\sqldrivers\oci qmake oci.pro mingw32-make
By% QTDIR%, means the folder in which the Qt source codes are located. In my case, it is: "C: \ QtSDK \ QtSources \ 4.8.1 \". Tip. Put this code in a batch file (name.bat).
The first issue that occurred was that some files were skipped: oci.h and qsqlcachedresult_p.h. The first is the result of some kind of problem, while mingw is trying to encounter the included folder above, and the second is probably a Qt error: qsqlcachedresult_p.h with the corresponding folder is actually missing.
The second problem was solved by copying and pasting the file from its actual location to the required, missing path. It is located in the folder "C: \ QtSDK \ QtSources \ 4.8.1 \ src \ sql \ kernel" and should be copied to "C: \ QtSDK \ Desktop \ Qt \ 4.8.1 \ mingw \ include \ QtSql \ private" ( private folder must be created).
According to the same source, the first problem should be fixed by placing the Oracle include path in the INCPATH variable in the makefile.release and makefile.debug files in% QTDIR% \ src \ plugins \ sqldrivers \ oci:
In debugging:
INCPATH = -I"c:\QtSDK\Desktop\Qt\4.8.1\mingw\include\QtCore" (...) -I"c:\Oracle\include" -I"c:\Oracle\lib\msvc"
In issue
INCPATH = -I"c:\QtSDK\Desktop\Qt\4.8.1\mingw\include\QtCore" (...) -I"c:\Oracle\include" -I"c:\Oracle\lib\msvc"
(I also put the lib path just for confirmation).
The problem with manually configuring these two files is that the next time you type “qmake oci.pro”, both of them will be recreated and the settings will be lost. So now you have to enter the Qt project code again, but without this line, "qmake oci.pro".
Second attempt:
When this was done, the first two problems were resolved, but ld.exe reported that it was not possible to find -loci (the oci.dll file). To fix this, I put the oci lib path in the LIBS variable:
In debugging:
LIBS = -L"c:\QtSDK\Desktop\Qt\4.8.1\mingw\lib" debug\qsqlocid_resource_res.o -loci -lQtSqld4 -lQtCored4 -L"c:\Oracle\lib\msvc"
The same goes for release.
Third attempt:
At the same time, the Qt Project code (without "qmake oci.pro") works fine. The only problem is that only debug libraries were created. Therefore, to fix this, I had to repeat some of the above steps in the following formula:
- Enter the source code for the Qt project with the qmake line changed to "qmake oci.pro" CONFIG + = release "".
- Edit the makefile.release file in% QTDIR% \ src \ plugins \ sqldrivers \ oci as previously done.
- Re-enter the Qt project code, now without the qmake line.
And now the dll and .a files for release mode should also appear in the corresponding folder inside% QTDIR% \ src \ plugins \ sqldrivers \ oci.
Finish:
Finally, copy the files libqsqloci4.a, qsqloci4.dll (release), libqsqlocid4.a, qsqlocid4.dll (debug) to C: \ QtSDK \ Desktop \ Qt \ 4.8.1 \ mingw \ plugins \ sqldrivers, the folder where the sql dll are located for MinGW to work with them, and you should be able to use OCI drivers in Qt without any problems. To check, go to Qt Creator and enter the following or similar code:
if (!QSqlDatabase::isDriverAvailable("QOCI")) cout << "FAILURE: No Oracle Database driver available." << endl; else cout << "SUCCESS: Oracle Database driver found." << endl;
The end of the textbook.
Drawn conclusions: lines
set INCLUDE=%INCLUDE%;c:\oracle\oci\include set LIB=%LIB%;c:\oracle\oci\lib\msvc
probably nothing helps in the source code of the Qt project. In addition, source code will compile the debug OCI library.
Hope this helps!
Momergil