[Solved] Problems building Oracle Call Interface (OCI) Plugin on Windows
-
wrote on 31 May 2011, 11:26 last edited by
The Qt documentation says that after obtaining some oracle files building the plugin should be this easy:
@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@But for some reason, this is what I've achieved so far:
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
[Edit: The step below is needed in order to have nmake.]
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-CPPThen 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\private 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"
[Edit: if it says that no such command or something similar, instead of nmake, type in the full path to nmake.]
Now I everything should be ready to run
@nmake@[Edit: I also got the missing -loci thing. Finally managed to fix that by replacing -loci with the path to oci.dll (C:\XEClient\bin\oci.dll) in both Makefile.Debug and Makefile.Release files at C:\QtSDK\QtSources\4.7.4\src\plugins\sqldrivers\oci.]
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.oAfter 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.cpp
moc_qsql_oci.o
qsql_oci.o
qsqloci4.dll
qsqloci_resource_res.oSo 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 and why I am spending most of the time trying to figure out this kind stuff instead of programming the software that is needed?
-
wrote on 31 May 2011, 12:37 last edited by
So you did try this in a plain main function with a dummy select like "SELECT SYSDATE FROM DUAL"?
Doing a quick grep, I cannot find any thread related code in the SQL modules and the OCI drivers.
-
wrote on 31 May 2011, 13:31 last edited by
Now when you mentioned it I tried to execute the addDatabase function and the mentioned dummy select in main, and it seems that it actually works there way or another. I was getting lost on all the complicated issues so that I couldn't see this simple solution on where to start finding the actual problem, thanks!
I haven't wrote a single line of any thread related code in this program and I have no idea where it originates from, but at least now I know the problem is somewhere in my code and not the drivers as I first suspected.
I'll report in on when I find any solutions or clues where this problem comes from.
-
wrote on 7 Jun 2011, 07:32 last edited by
Okay, I found out where the problem was some time ago but I didn't have any time to write it here.
So, I was able to build a working plugin as mentioned above. The last problem was that I was calling a member function of a class that handles the database before I called the constructor of the class.
Feeling a bit shamed here about that :PSo the problem and solution was rather trivial here, I just didn't notice it. The problem with noticing this problem is that the compiler or builder doesn't think that calling member functions of a not-constructed class is actually an error (C++, that is).
-
wrote on 7 Jun 2011, 08:55 last edited by
[quote author="ionwind" date="1307431973"]
So the problem and solution was rather trivial here, I just didn't notice it. The problem with noticing this problem is that the compiler or builder doesn't think that calling member functions of a not-constructed class is actually an error (C++, that is).[/quote]If you have pointers, the compiler can't know. You might have initialized that pointer somewhere in a plugin or a lib, which the compiler doesn't even see on compile time.
So, this happens from time to time - good to know that the solution is that easy and that it is not a bug in the libs :)
-
wrote on 19 Jul 2011, 20:43 last edited by
Hi,
I am slogging with the OCI plugin for Qt4.7.3.
After completing all the steps mentioned by ionwind when I execute nmake I get the following error:
@g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-ps
eudo-reloc -mthreads -Wl -shared -Wl,--out-implib,debug\libqsqlocid4.a -o debug
qsqlocid4.dll debug/main.o debug/qsql_oci.o debug/moc_qsql_oci.o -L"c:\QtSDK
Desktop\Qt\4.7.3\mingw\lib" debug\qsqlocid_resource_res.o -loci -lQtSqld4 -lQtCo
red4
c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: cannot find -loci
collect2: ld returned 1 exit status
NMAKE : fatal error U1077: 'C:\QtSDK\mingw\bin\g++.EXE' : return code '0x1'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 10.0\VC\bi
n\nmake.exe"' : return code '0x2'
Stop.@The compiler says -loci can't be found.
I am running Oracle Express 10g on a Windows 7 Ultimate machine.
What is that I am missing here?
-
wrote on 19 Jul 2011, 21:27 last edited by
I found the problem. OCI.dll path was missing in environment variable.
Once updated I was able to compile the driver.
-
wrote on 5 Dec 2011, 17:00 last edited by
how did you add oci.dll path
-
wrote on 5 Dec 2011, 17:09 last edited by
Adding the path to environment variable depends on the system you're using. Try searching the web with "add environment variable to path".
I'd gladly give more specific advice if I could remember better how I did things back then. -
wrote on 5 Dec 2011, 17:14 last edited by
I have added to PATH variable this C:\XEClient\bin\oci.dll
But how to use it? -
wrote on 5 Dec 2011, 17:15 last edited by
And when I perform mingw32-make i get error that -loci is missing
-
wrote on 5 Dec 2011, 18:51 last edited by
Avoid giving specific file path in environment variable, so update the path variable with C:\XEClient\bin
If you still get the -loci missing error, try copying the dll to system directory (eg. C:\windows\system32) and your make should find it without any problem.
-
wrote on 5 Dec 2011, 18:57 last edited by
You mean like perform this line : set PATH=%PATH%;c:\Windows\System32
before nmake?
If that's what I need to do then it's not working still.
Any other suggestion -
wrote on 5 Dec 2011, 19:02 last edited by
Use set PATH = %PATH%;c:\XEClient\bin & then run nmake or copy the DLL file to windows\system32
Another option is to edit the environment variable in system properties dialog to make it accessible from all locations.
[Control Panel -> System -> Advanced System Settings -> Advanced Tab -> Environment Variable]Sometimes a system restart is required for the changes to become effective.
-
wrote on 5 Dec 2011, 19:12 last edited by
nothing seems to be working
i have done what you have said, even went to enviroment dialog and make new user variable
PATH c:\XEClient\bin
and system variable had path already so I added c:\XEClient\bin and c:\windows\system32 and it's not working -
wrote on 5 Dec 2011, 19:14 last edited by
Can you mail me the nmake output? May help in solving the issue.
-
wrote on 5 Dec 2011, 19:23 last edited by
@mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directoryC:/QtSDK/QtSources/4.7.4/src/plugins/sqldrivers/oci' g++ -mthreads -shared -Wl,--out-implib,debug\libqsqlocid4.a -o debug\qsqlocid4.dll debug/main.o debug/qsql_oci.o debug/moc_qsql_oci.o -L"c:\QtSDK\Desktop\Qt\4.7.4\mingw\lib" debug\qsqlocid_resource_res.o -loci -lQtSqld4 -lQtCored4 mingw32-make[1]: Leaving directory
C:/QtSDK/QtSources/4.7.4/src/plugins/sqldrivers/oci'
@
I didn't get all code from output hmm strange -
wrote on 5 Dec 2011, 19:27 last edited by
is this helping or you need all that is on screen, because i am using this command nmake > c:\cmd.txt and I don't get all code from it
-
wrote on 5 Dec 2011, 19:33 last edited by
from the above i can't make out if there's an error, it appears that make has found the dependency and driver has been compiled.
What is there in your QTDIR\src\plugins\sqldrivers\oci\debug directory? if possible send the full debug to nilotpal2007[AT]gmail[DOT]com
-
wrote on 27 Dec 2011, 11:46 last edited by
To those who might have problems with -loci, try replacing -loci with the path to oci.dll (like C:\XEClient\bin\oci.dll) in the both Makefile.Release and Makefile.Debug files on LIBS section.