QOCI and Android
I'm trying to connect directly to the Oracle database from my android device(over VPN).
I create libqsqloci.so in Ubuntu and try use it on my project for Android.
But when I execute my program - I see error -
libtest_con_form.so: (null):0 ((null)): QSqlDatabase: QOCI driver not loaded libtest_con_form.so: (null):0 ((null)): QSqlDatabase: available drivers: QSQLITE QOCI QOCI8
QOCI available but not loaded !!!!!
Please help me!
Hi and welcome to devnet,
How did you build that plugin ?
Apparently it was deeply hoped that the library compiled under ubuntu would suit for android.
I create plugin from this guid
but in this moment page is not displayed. But i have listing:
Creating Oracle OCI Driver Plugin for Qt 5.0.1
March 27,2013 by Thomas
Before we begin, we assume that you downloaded and installed QT 5.0.1 correctly already.
Firstly, download required files below from Oracle website:
and extract these files into a local directory. In our case, files have been extracted to /home/developer/Desktop /oracle directory.
Create libdntsh.so file here (otherwise "make" will not be able to link -Iclntsh ) by running following command:
In -s libdntsh.so.11.1 libdntsh.so
Now, go to QT 5.0.1 source directory (where you extracted QT 5.0.1 source to):
cd /home/developer/DownIoads/qt-everywhere-opensource-src-5.0.1/qtbase/src/plugins /sqldrivers/oci/
Run qmake here (Don't forget to include oracle "include" path and link to libdntsh.so shared object file).
qmake "INCLUDEPATH+=/home/developer/Desktop/oracle/sdk/include" "LIBS+=-L/home/developer /Desktop/oracle/instantclient_ll_2 -Iclntsh" oci.pro
This creates Makefile required for make command. Finally,run:
End of output will be like this:
g++ -Wl,--no-undefined -Wl,-01 -Wl,-rpath,/root/Qt5.0.1/5.0.1/gcc -wi,-rpath,/root/Qt5.0.1/5.0.l/gc red/main.о .obj/release-shared/qsqloci.о .obj/felease-shared/mocqsqloci.о -L/home/developer/Des -5.0.1/qtbase/lib -IQtSSql -IQtSCore -Ipthread | mv -f libqsqloci.so ../../../../plugins/sqldrivers/
Now take a look at the last row,it says:
mv -f libqsqloci.so ../../../../plugins/sqldrivers/.
This command moved libqsqloci.so file to ../../../../plugins/sqldrivers/ (That is /home/developer/Downloads /qt-everywhere-opensource-src-5.0.1/qtbase/plugins/sqldrivers/ directory. ). Now let's list files in "../../../ /plugins/sqldrivers/" directory:
[root@develop oci]# ll ../../../../plugins/sqldrivers/ total 996
-rwxr-xr-x. 1 root root 765891 Mar 11 16:50 libqsqlite.so
-rwxr-xr-x. 1 root root 133290 Mar 26 13:41 libqsqloci.so
-rwxr-xr-x. 1 root root 116726 Mar 11 16:50 libqsqlodbc.so
At last, we created oracle OCI plugin. Now, copy this file to your Qt plugin directory. If you don't know which directory it is, you can see it using QApplication::libraryPaths(). In our case, we moved it to /root/Qt5.0.1/5.0.1 /gcc/plugins/sqldrivers/ directory.
If Qt still complains that QOCI driver is not installed but it is in plugins directory already, you should check if you linked your code to libqsqloci.so file and oracle shared object files. If not, you should add these options :
-Iqsqloci -Iclntsh -Innzll
and tell the linker which directory they are at (it is -L/home/developer/Desktop/oracle/instantclient_ll_2 and -L/root/Qt5.0.1/5.0.1/gcc/plugins/sqldrivers/ in our case.).
If you encounter an "error while loading shared libraries" error when you want to start your program,you can overcome this problem either by adding directories of these .so files to $LD_LIBRARY_PATH or create a symbolic link of them in default library search path like /usr/lib.
Also, if you encounter an error like this one:
[root@develop src]# ./src
./src: error while loading shared libraries: libnnzll.so: cannot enable executable stack as shared object requires: Permission denied
Execute this command:
You are building a library for your desktop Ubuntu not for your device Android which might also be ARM rather than x86. That won't work.
On a side note, you should stop developing as root, you might break your machine without any warning.
It be virual mashine on virtual box.
And what should I do? How do I compile a QOCI plugin for android
You need to check whether Oracle provide client libraries for Android.