views:

268

answers:

1

Hi,

My application accesses an Oracle database through Qt's QSqlDatabase class.

I'm compiling Qt as static for the release build, but I can't seem to be able to get rid of OCI.dll dependency. I'm trying to link against oci.lib (as available in Oracle's Instant Client with SDK).

Here's my configure line :

configure -qt-libjpeg -qt-zlib -qt-libpng -nomake examples -nomake demos -no-exceptions -no-stl -no-rtti -no-qt3support -no-scripttools -no-openssl -no-opengl -no-phonon -no-style-motif -no-style-cde -no-style-cleanlooks -no-style-plastique -static -release -opensource -plugin-sql-oci -plugin-sql-sqlite -platform win32-msvc2005

I link against oci.h and oci.lib in the SDK's folder by using :

set INCLUDE=C:\oracle\instantclient\sdk\include;%INCLUDE%
set LIB=C:\oracle\instantclient\sdk\lib\msvc;%LIB%

Then, once Qt is compiled, I use the following lines in my *.pro file :

QT += sql
CONFIG += static
LIBS += C:\oracle\instantclient\sdk\lib\msvc\oci.lib
QTPLUGIN += qsqloci

Then, in my main.cpp, I add the following commands to statically compile OCI plugin in the application :

#include <QtPlugin>

Q_IMPORT_PLUGIN(qsqloci)

After compiling the project, I test it on my workstation and it works (as I have Oracle Instant Client installed). When I try on another workstation, I always get the message:

This application has failed to start because OCI.dll was not found. Re-installing this application may fix this problem.

I don't understand why I still need OCI.dll, as my statically linked application is supposed to link to oci.lib instead.

Is there any Qt people here that might have a solution for me ?

Thanks a lot !

STL

+2  A: 

The .lib file you linked is not what you think it is. It is the import library for the DLL, the linker needs it so it knows what functions are implemented by oci.dll. I don't see a static version of the library available from Oracle but didn't look too hard. That's pretty typical for dbase interfaces.

You'll need to follow the deployment instructions for oci.dll, "OCI Instant Client Installation Process" in this document. Changing the PATH, oh joy.

Hans Passant
Thanks for the answer !Yet, I know that Charles Burns was able to statically link the OCI plugin (without oci.dll or so it seems) : http://www.formortals.com/how-to-statically-link-qt-4/If there is really no other way to use Oracle than distribute a few DLLs with my app, then I'll do it.
STL
He's talking about statically linking QT, not the oracle provider. I reckon most shops that use oracle already have a provider installed on their machines.
Hans Passant
This might just be why it didn't seem to work for me !Anyway, it works just fine with the 3 DLLs, so I guess I'll go this way. Thanks again !
STL