📜 ⬆️ ⬇️

Kubuntu 9.10 + Qt4 + Oracle Express Edition

Given:
Kubuntu 9.10 (the version of kubuntu in this case does not matter)
with an installed Qt and Oracle Express Edition development kit from repositories.
Task:
Establish a connection from a Qt program to a database.

Decision
For some reason, there is no compiled driver for Oracle in the repository, but the sources for the sql driver itself
available in Qt source.

First we need to download the Oracle Instant Client.
www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html
Please note that if you have Oracle Express Edition
then you need files from branch 10.2
Download archive
unzip it
and go to the next path (address)
in my case it is
/ home / swift / Tmp / instantclient_10_2 / sdk
')
You are interested in the contents of the include directory
as root, create the directory /usr/include/oracle/10.2
and copy the contents of this folder into it



Next, go to the site qt.nokia.com/downloads/linux-x11-cpp
And download the source Qt.
(The Qt 4.5.2 version is available in the Kubuntu repository, the site offers 4.5.3 to be downloaded by default, which is not essential in principle
if you want to download the source code of Qt 4.5.2 just change the link in one link and quietly download it with the same wget)

In my case, I downloaded it at
/ home / swift / Tmp

unzip the archive
and go to the next path (address)
/home/swift/Tmp/qt-x11-opensource-src-4.5.2/src/plugins/sqldrivers/oci

There should be three files
README
main.cpp
oci.pro

There we execute the following command
qmake "INCLUDEPATH + = / usr / include / oracle / 10.2 /" usr / lib / oracle / xe / app / oracle / product / 10.2.0 / server / lib / -lclntsh -lnnz10 "oci.pro

Pay attention to the paths, they must meet the paths where you have installed Oracle XE
Execute the command and get the Makefile
We go into it and find the line that starts with INCPATH
Our task is to specify that the header files included in the source are.
In my case, this resulted in adding the following line there.
-I / home / swift / Tmp / qt-x11-opensource-src-4.5.2 / include

Save the file
and run
make first
then make install (this command must be run as root)

Then you need to rewrite the hash of the dynamic libraries. This is done using the ldconfig command.

Well, now we are testing the program itself.

#include #include int main (int argc, char ** argv)
{
QApplication a (argc, argv);
QMainWindow mainwin;
...
QSqlDatabase db;
db.addDatabase ("QOCI");
db.setDatabaseName ("XE");
db.setUserName ("system");
db.setPassword ("secret_word");
...
mainwin.show ();
return a.exec ();
}

the program is compiled as standard
qmake -project
qmake
make

Source: https://habr.com/ru/post/76488/


All Articles