Properly loading QOCI driver on macOS[Solved]
-
I managed to successfully build the qoci drivers needed by Qt to communicate with an Oracle db, When trying to connect though I get the Driver not loaded error. The same thing had happened to me with the Mysql drivers too, but I solved it using the install_name_tool command like such:
@install_name_tool -change libmysqlclient.18.dylib /Users/administrator/Downloads/mysql-5.6.21-osx10.8-x86_64/lib/libmysqlclient_r.18.dylib libqsqlmysql.dylib@
But for this case I am not sure how to solve the error, I tried copying all the libraries of instant client in all possible locations but still nothing.
Has anyone else had this issue in the past, any idea on what should I do to solve it?
-
Hi,
You should run your application QT_DEBUG_PLUGINS set to 1 to see where it fails
[edit: corrected typo]
-
Hey SGaist,
Since QT_DEBUG_PLUGINGS is not all that well documented I randomly tried the command
@set QT_DEBUG_PLUGINGS = 1@and since I saw nothing I went inside my app directory at Contents>MacOS where the executable is and tried
@./DbConnect -QT_DEBUG_PLUGINS=1@
What I noticed is that if I run my app from there it loads the plugin and then it freezes until it times out (presumably because my listener is not turned on). Please not that I had previously created a sqldrivers folder in this directory containing all the libraries of oracles' instant client.
How come this happens?
EDIT
I just confirmed it, I can actually connect if I run the executable inside my app, but not if just double click that app, on the later case the driver won't load.
-
Then you probably have a path issue with either the plugin or one of it's dependencies
-
Most probably, do you know what the correct install_name_tool command would be for my case?
EDIT
ok i found about the existence of otool
here is the output if I run it for the qosi driver
@$ otool -L libqsqloci.dylib
libqsqloci.dylib:
libqsqloci.dylib (compatibility version 0.0.0, current version 0.0.0)
/ade/b/3071542110/oracle/rdbms/lib/libclntsh.dylib.11.1 (compatibility version 0.0.0, current version 0.0.0)
/Users/administrator/Qt/5.3/clang_64/lib/QtSql.framework/Versions/5/QtSql (compatibility version 5.3.0, current version 5.3.1)
/Users/administrator/Qt/5.3/clang_64/lib/QtCore.framework/Versions/5/QtCore (compatibility version 5.3.0, current version 5.3.1)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)@It says that it needs libclntsh.dylib.11.1 at a directory that doesn't even exist
so if I try to change it I can end up with this
$ install_name_tool -change /ade/b/3071542110/oracle/rdbms/lib/libclntsh.dylib.11.1 /Users/administrator/Downloads/QtTests/libs/libclntsh.dylib.11.1 libqsqloci.dylib
$ otool -L libqsqloci.dylib
libqsqloci.dylib:
libqsqloci.dylib (compatibility version 0.0.0, current version 0.0.0)
/Users/administrator/Downloads/QtTests/libs/libclntsh.dylib.11.1 (compatibility version 0.0.0, current version 0.0.0)
/Users/administrator/Qt/5.3/clang_64/lib/QtSql.framework/Versions/5/QtSql (compatibility version 5.3.0, current version 5.3.1)
/Users/administrator/Qt/5.3/clang_64/lib/QtCore.framework/Versions/5/QtCore (compatibility version 5.3.0, current version 5.3.1)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)So now it is pointing at the right path, but yet it refuses to work.
-
What does otool say about libclntsh ?
-
Even though what I described above worked for MySql, it does not work for Oracle db, what you have to do, at least for me is to copy the instantclient libraries to /usr/lib. Moreover if you want to use sqlplus then copy all the content from the sql plus package from oracle at /usr/bin. I still don't know why install_name_tool didn't do the trick as I checked the dependencies.
-
Did you also check the dependencies themselves ?
-
Yes I followed all the links, but most probably you are right I must have missed something while changing the links for the libraries. Now what remains is building the db2 drivers and I finally succeed in managing to connect to all databases, a somewhat pointless task but I learned a few things along the way.