PDA

View Full Version : Creating MySQL and Oracle (OCI) plugins.



Blando
14th May 2010, 17:44
Environment:


Windows 7 x64 Ultimate
Visual Studio 2008 w/ Qt Integration
Qt 4.6.2 libraries VS2008

configure (no other switches)



ABSTRACT:


I have Qt configured and built already. I have working examples and everything appears fine. What I now is to build the MySQL and the Oracle OCI plugins. I have downloaded the required sources for both databases. (the include, lib)
I have followed the Qt Documentation for building the plugins but I get LNK errors for both builds. Below is the error I get for building MySQL plugin. The Oracle one is very similar.



..\..\..\..\plugins\sqldrivers\qsqlmysqld4.dll : fatal error LNK1120: 50 unresol
ved externals
NMAKE : fatal error U1077: '"c:\My Programs\Microsoft Visual Studio 9.0\VC\BIN\l
ink.EXE"' : return code '0x460'
Stop.
NMAKE : fatal error U1077: '"c:\My Programs\Microsoft Visual Studio 9.0\VC\BIN\n
make.exe"' : return code '0x2'
Stop.


Any help would be greatly appreciated. What am I doing wrong?

-Blando

ChrisW67
15th May 2010, 00:30
The MySQL and Oracle link libraries are not being found by the linker. Related error messages should be showing above the snippet you posted.

You need to put the MySQL/Oracle bin or lib directories in the linker's library search path. The VC++ linker can be told to look in other places using the LIB environment variable or /LIBPATH command line option. If this were your own project you could adjust the LIBS variable in your PRO file.

Blando
15th May 2010, 01:55
I think I have already done this.

Starting from scratch just trying to build OCI.



cd c:\Qt\4.6.2\sql\plugins\sqldrivers\oci
qmake oci.pro


Results in: "Cannot open include file: 'oci.h' ...." <---GOOD



nmake distclean
set include=%include%c:\Oracle\sdk\include;
qmake oci.pro
nmake


Results in: "fatal error LNK1104: cannot open file 'oci.lib'......" <---GOOD

Finally,


nmake distclean
set lib=%lib%c:\Oracle\sdk\lib\msvc;
qmake oci.pro
nmake


..\..\..\..\plugins\sqldrivers\qsqlocid4.dll : fatal error LNK1120: 29 unresolved externals
NMAKE : fatal error U1077: '"c:\My Programs\Microsoft Visual Studio 9.0\VC\BIN\link.EXE"' : return c
ode '0x460'
Stop.
NMAKE : fatal error U1077: '"c:\My Programs\Microsoft Visual Studio 9.0\VC\BIN\nmake.exe"' : return
code '0x2'
Stop.



I'm not sure what else I need to do. I have done everything in the documentation.
I also added c:\Oracle to PATH and still get the 29 unresolved externals problem.

I am using the Oracle Instant Client Basic (c:\Oracle) and Oracle Instant Client SDK (c:\Oracle\sdk)

I believe if I can get this resolved then I will be able to fix MySQL as well. Similar issues for both.

A foot in the right direction would be great.

Thanks.
-Blando:confused:

Blando
15th May 2010, 08:45
Marvelous.

SOLVED:

My problem was that I wasn't using the correct version and/or I had a version mismatch.

I deleted my entire c:\Oracle and started fresh.

I followed The Oracle God, Mark Williams, tutorial here. (http://oradim.blogspot.com/2009/07/getting-started-with-occi-windows.html)

I did exactly what he stated, using the older version 11.1.0.6.0
Download Oracle Instant Client BASIC x32 11.1.0.6.0
Download Oracle Instant Client SDK x32 11.1.0.6.0
Download Oracle C++ Call Interface Visual C++ 9 (VS 2008) x32

I built his sample code to make sure everything was right. Once I was able to build successfully then I went to Qt.



Visual Studio Command Line
cd c:\Qt\4.6.2\src\plugins\sqldrivers\oci
set include=%include%c:\Oracle\sdk\include;
set lib=%lib%c:\Oracle\sdk\lib\msvc\vc9;
set path=%path%c:\Oracle\vc9; <--directory you will create from Mark Williams instructions posted above.
set path=%path%c:\Oracle;
qmake oci.pro
nmake

Error Free!!

Created sample Qt app to test.


#include "oci_test_app.h"
#include <QtGui/QApplication>
#include <QSqlDatabase>
#include <QSqlError>
#include <QMessageBox>

bool createConnection()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QOCI");
db.setHostName("test");
db.setDatabaseName("test");
db.setUserName("test");
db.setPassword("test");
if(!db.open())
{
QMessageBox::critical(0, QObject::tr("Database Error"), db.lastError().text());
return false;
}

}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
if(!createConnection())
return 1;
OCI_TEST_APP w;
w.show();
return a.exec();
}


No errors on build. Error free compilation.
Got the Oracle Error Message on run. <-- GOOD
Now we are set to go.

-Blando