PDA

View Full Version : Oracle Call Interface (OCI) driver problems



Ionwind
25th May 2011, 15:44
So, now I'm getting rather desperate here. Old threads here don't seem to be of any help.
In 2010 I managed to compile and use OCI driver with my program.

Now however, I installed Qt Creator 2.2.0 (Qt 4.7.4) on Windows XP and now I am completely unable to do anything with the Oracle database.

First of all, I would try to compile the driver again but there's no src directory nor the oci.pro file.

Secondly, I still have the driver that I compiled a year ago, I've tried to use that file but so far I haven't got any results.

Is there any kind soul out there who could tell me what I'm supposed to do if I want to connect my program to oracle database? Qt help doesn't make me any wiser :(

Ionwind
26th May 2011, 12:44
Now I figured out that the SDK 1.1.1 doesn't seem to include the libraries for some reason so I downloaded and installed the libraries (4.7.3). I suppose I have all the files so now I've managed to get myself stuck to line 5 in the following (using Qt 4.7.3 Command Prompt):


set INCLUDE=%INCLUDE%;c:\oracle\oci\include
set LIB=%LIB%;c:\oracle\oci\lib\msvc
cd %QTDIR%\src\plugins\sqldrivers\oci
qmake oci.pro
nmake


When I try to run (n)make, I get an error telling me that the oci.h file is not found. How I am supposed to tell to make that the file exists there? oci.h is located in the c:\oracle\oci\include but why make doesn't recognize it?

Ionwind
31st May 2011, 12:53
(I'm running on Win XP SP3 by the way)

Everything seemed to lead me to a dead-end, so I did the following:

I uninstalled everything that had anything to do with Qt and Oracle

I got the Oracle Database 10g Express Client from http://www.oracle.com/technetwork/database/express-edition/downloads/102xewinsoft-090667.html and installed it to its default path C:\XEClient

I got Qt SDK 1.1.1 (offline installer) from http://qt.nokia.com/downloads and made a custom installation. From the components I checked Documentation, Qt Examples, MinGW 4.4, Qt Designer, Desktop Qt 4.7.3 - MINGW and Qt Linguist. I installed it to its default path of C:\QtSDK

Just to make sure (don't know excactly why) I reinstalled also Microsoft Visual C++ 2010 Express http://www.microsoft.com/express/Downloads/#2010-Visual-CPP

Then when everything was (re)installed, I started the Maintain Qt SDK tool found from the Start menu or through Qt Creator (Help - Start updater). From there (from Package manager tab) I checked under Miscellaneous - Qt Sources the Qt 4.7.3 Sources component.

Then I set the environment variables (right click my computer - properties - advanced - environment variables) and added there LIB with value C:\XEClient\oci\lib\msvc and INCLUDE with value C:\XEClient\oci\include

After this I ran the Qt 4.7.3 for Desktop (MinGW) command prompt from the start menu and I wrote in the following

set QTDIR=C:\QtSDK\QtSources\4.7.3
cd %QTDIR%\src\plugins\sqldrivers\oci
qmake oci.pro

If I recall correctly everything worked fine until this point. Then I tried to run nmake but then I got an error that C:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtSql directory was missing a file, private\qsqlcachedresult_p.h so I searched for that file and I found it from C:\QtSDK\QtSources\4.7.3\src\sql\kernel directory, so I created a the missing directory C:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtSql\priv ate and copied the qsqlcachedresult_p.h there.

After that I tried to run nmake again but it still puked on my face, complaining about missing oci.h file. So I manually edited Makefile.release and Makefile.debug files in %QTDIR%\src\plugins\sqldrivers\oci. I added there in the INCPATH section the following: -I"C:\XEClient\oci\include"

Now I everything should be ready to run

nmake

FINALLY after that nmake didn't complain about anything and it made the following files in the %QTDIR%\src\plugins\sqldrivers\oci\debug directory:

libsqlocid4.a
main.o
moc_qsql_oci.cpp
moc_qsql_oci.o
qsql_oci.o
qsqlocid3.dll
qsqlocid_resource_res.o

After that I ran

nmake release
which gave me the following files to %QTDIR%\src\plugins\sqldrivers\oci\release directory:

libsqloci4.a
main.o
moc_qsql_oci.o
qsql_oci.o
qsqloci4.dll
qsqloci_resource_res.o


So now I should have the OCI plugin. According to my notions, the .a and .dll files from both debug and release folders should be copied to C:\QtSDK\Desktop\Qt\4.7.3\mingw\plugins\sqldrivers directory

This way when I run my build in Debug or Release mode the code

qDebug() << QSqlDatabase::drivers();
Shows in debug screen that I have QOCI and QOCI8 available.

HOWEVER. I am now getting the following error when I try to use
QSqlDatabase::addDatabase("QOCI")

QObject::moveToThread: Current thread (0x3e5448) is not the object's thread (0xa17de28).
Cannot move to target thread (0x3e5448)

Now, is there anyone who could tell what is wrong here?

Ionwind
7th June 2011, 09:38
Finally solved this last problem. So I managed to build a working plugin with the procedure mentioned above. The last problem with the threads (that shouldn't have anything to do with this) occurred because I was calling a member function of a class that wasn't yet constructed. The builder/compiler doesn't think that this is an error, so it's quite hard to notice it.

Anyway, problem solved.