November 27, 2011

hkdewitt hkdewitt
Lab Rat
10 posts

Loading the OCI driver on the MAC

Page  
1

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.

16 replies

November 27, 2011

Volker Volker
Ant Farmer
5428 posts

The variable is named DYLD_LIBRARY_PATH on the mac and it must contain the directory where all the OCI libraries are stored.

November 27, 2011

hkdewitt hkdewitt
Lab Rat
10 posts

I added that and still have the same result

November 27, 2011

Volker Volker
Ant Farmer
5428 posts

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:

  1. #!/bin/sh
  2.  
  3. if [ "x$DYLD_LIBRARY_PATH" = "x" ]; then
  4.   DYLD_LIBRARY_PATH=/usr/local/Oracle/instantclient_10_2
  5. else
  6.   DYLD_LIBRARY_PATH=DYLD_LIBRARY_PATH:/usr/local/Oracle/instantclient_10_2
  7. fi
  8.  
  9. export DYLD_LIBRARY_PATH
  10. 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!

November 27, 2011

hkdewitt hkdewitt
Lab Rat
10 posts

1) 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
2) oracle is loaded in /usr/local/oracle/instantclient_10_2
3) I added ORACLE_HOME, etc in /etc/launchd.conf.
4) 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.

November 27, 2011

Volker Volker
Ant Farmer
5428 posts

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

  1. 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:

  1. CONFIG -= x86_64 ppc64 ppc
  2. 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

November 27, 2011

hkdewitt hkdewitt
Lab Rat
10 posts

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.

November 27, 2011

Volker Volker
Ant Farmer
5428 posts

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.

November 27, 2011

hkdewitt hkdewitt
Lab Rat
10 posts

Thanks for your help. I checked and sqlplus is an i386 while the library is x86-64. I will post more when I know something further.

November 27, 2011

Volker Volker
Ant Farmer
5428 posts

Ok, seems you mix sqlplus from /b/32…. with instant client libs from /usr/local/….

You should check your paths here.

November 30, 2011

hkdewitt hkdewitt
Lab Rat
10 posts

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.

December 1, 2011

Volker Volker
Ant Farmer
5428 posts

libclntsh is included in the instant client development package.

  • check the architectures in libclntsh
  • make sure to build your application and the SQL plugin against the very same architecture(s)

See previous comments for how to do that

December 22, 2011

hkdewitt hkdewitt
Lab Rat
10 posts

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:/sbin

Is 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.

December 22, 2011

Volker Volker
Ant Farmer
5428 posts

Make sure to build the plugin and your application only for the x86/i386 architecture. The instant client libraries usually are not fat binaries. Add the CONFIG entries to the plugin’s .pro file as well as to that of your application.

December 22, 2011

hkdewitt hkdewitt
Lab Rat
10 posts

I added the CONFIG entries to both with no impact. Also, I have installed the x86_64 version of the instant client for MAC. lipo reports: Non-fat file: libclntsh.dylib is architecture: x86_64

December 22, 2011

Volker Volker
Ant Farmer
5428 posts

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 ×86_64 arch, as well as your application. This should be everything.

Page  
1

  ‹‹ [help]building qt 4.7.4 in mingw      Building Qt5 for Embedded Linux ARM - compiler problems ››

You must log in to post a reply. Not a member yet? Register here!