Loading the OCI driver on the MAC
-
I have built the OCI plugin on the MAC, placed the resulting file in all the same locations as the drivers found (SQLITE, ODBC), set the ORACLE_HOME and LD_LIBRARY_PATH environment variables and added the oracle location to the PATH environment variable, yet a call to QSqlDatabaes::addDatabase ("QOCI") fails with the applications indicating that the QOCI driver not loaded, available drivers are QSQLITE QODBC3 QODBC.
What more needs to be done to make the OCI driver load?
What tools are there to determine what is wrong?
I have successfully done the above on a PC.
-
Does sqlplus work from the command line?
Where did you install the Oracle libs, what do you add to DYLD_LIBRARY_PATH?This is my shell wrapper to start sqlplus on my Mac:
@
#!/bin/shif [ "x$DYLD_LIBRARY_PATH" = "x" ]; then
DYLD_LIBRARY_PATH=/usr/local/Oracle/instantclient_10_2
else
DYLD_LIBRARY_PATH=DYLD_LIBRARY_PATH:/usr/local/Oracle/instantclient_10_2
fiexport DYLD_LIBRARY_PATH
exec /usr/local/Oracle/instantclient_10_2/sqlplus $@
@Oh, and a last question - do you start your application from the command line or via Finder? If you use the latter, then the manipulation of DYLD_LIBRARY_PATH on the commad line does not have any effect on apps started with the Finder!
-
- I believe that I had sqlplus working at one point, but at the moment I get: dyld: Library not loaded: /b/32_216/rdbms/lib/libclntsh.dylib.10.1
no suitable image found. Did find: libclntsh.dylib.10.1: mach-o, but wrong architecture - oracle is loaded in /usr/local/oracle/instantclient_10_2
- I added ORACLE_HOME, etc in /etc/launchd.conf.
- The application is being launched at the moment from QtCreater, but launching from the finder has same result.
I suspect that the information in 1 above is telling me something that I need to research. I am running on a Mac-Mini for the MAC version of the application.
- I believe that I had sqlplus working at one point, but at the moment I get: dyld: Library not loaded: /b/32_216/rdbms/lib/libclntsh.dylib.10.1
-
Seems like a library mismatch here: Your application tries to load the lib in /b/32_216/rdbms/lib/libclntsh.dylib.10.1, but you state that you have instant client installed in /usr/local/oracle/instantclient_10_2. You should stick to either one, I'm not sure whether libclntsh.dylib.10.1 of these two installations are compatible. I recommend building and running both the Qt OCI plugin and your application against the instant client.
Then there's a second problem: The oracle instant client is built as x86 32 bit binary only. Please check the output of
@
lipo -info /usr/local/Oracle/instantclient_10_2/libclntsh.dylib.10.1
@Most probably you get
Non-fat file: /usr/local/Oracle/instantclient_10_2/libclntsh.dylib.10.1 is architecture: i386
In that case, make sure to build your Qt application only as 32bit X86 application. To ensure this add this to your .pro file:
@
CONFIG -= x86_64 ppc64 ppc
CONFIG *= i386
@If you use a precompiled Qt library, then you're lost at this point, as those only contain X86 64 bit code. You must build Qt manually in this case.
Last, please show the conetents of your DYLD_LIBRARY_PATH - you did not mention
-
sqlplus gave me the message with the other directory, not my application.
DYLD_LIBRARY_PATH=usr/local/oracle/instantclient_10_2
I did see the message about i386 somewhere in this process but making the suggested changes to the .pro file did not change the results.
I am wondering if I have the wrong version of oracle installed.
-
As far as I know there's only one version of the oracle instant client for the Mac (32 bit Intel).
But the first step is to make sqplus running, as long as you cannot connect to your database with that tool it's quite useless to try with Qt, as you cannot be sure to have a working oracle installation.
-
I have re-installed the latest Oracle. I now have sqlplus working, but still can not load the OCI plugin. I have attempted to rebuild the plugin against the new installation and can not link the plugin. I either get 'library not found for -lclntsh' or if I remove the requirement for the library, a lot of missing references from the linker. I don't believe that the referenced library is included in the installation. Does it need to be built also or am I missing something.
-
After time to get some other work done, I am back at this problem.
One missing point is the need to link the dynamic library:
ln -s libclntsh.dylib.10.1 libclntsh.dylib
I am using QtCreator to build libqsqloci.dylib and now I am able to build the libqsqloci.dylib, however I still can not get to work. I have attempted to load the file as a plugin (QPluginLoader) and get the message that it is not a valid plugin.
Should the library be built from the command line instead?
Both the application, the built library and the installed Oracle are X86-64
The following environment variables are set:
ORACLE_HOME=/usr/local/oracle/instantclient_10_2
DYLD_LIBRARY_PATH=/usr/local/oracle/instantclient_10_2/libs
PATH=/usr/bin:/Users/wscadmin/QtSDK/Desktop/Qt/4.7.3/gcc/bin:/usr/bin:/bin:/usr/sbin:/sbinIs there some other variable needed?
I do not really need the functionality of the plug in and it would be OK to load the plugin statically, but every time I provide the Oracle library to the executable, it ceases to function.
-
Sorry, I'm out here. I don't know how your Qt, the plugin and the app is built in detail. All I can say is that it works in principle. I have a manually built Qt here, with x86/i386 and ppc arch, no 64 bit.
If you have a x86_64 oracle installation, your Qt must contain x86_64 architecture too. The plugin must be built using only x86_64 arch, as well as your application. This should be everything.
-
While I ultimately got this to work on Snow Leopard, we are moving to Lion and the existing OCI library does not appear to work on Lion. I can even take the Snow Leopard application with the OCI driver included in it and get the message 'Driver Not Loaded'. Is there something special that needs to be done on Lion to make this work?