Installing OCILIB
- Compatibilities
Actual version of OCILIB has been validated on :
- Platforms: Windows, HP/UX, Linux, Mac OS, Solaris, AIX, OpenVMS
- Architectures: 32/64bits
- Compilers: GCC / MinGW, MS Compilers, IBM XLC, CCs, LabView
- Oracle versions: 8i, 9i, 10g, 11g
Please, contact the author if you have validated OCILIB on platforms or compilers not listed here.
- Global build options
OCILIB supports the following global build options:
=> Oracle import:
- OCI_IMPORT_LINKAGE for linkage at compile time (default on unixes)
- OCI_IMPORT_RUNTIME for runtime loading (default with prebuilt OCILIB libraries on MS Windows)
=> Oracle charset
- OCI_CHARSET_ANSI for ANSI (default)
- OCI_CHARSET_UNICODE for Unicode
- OCI_CHARSET_MIXED (ANSI for metadata, Unicode for user data)
=> Calling convention (WINDOWS ONLY)
- OCI_API = __cdecl or blank for C/C++ only ! (default)
- OCI_API = __stdcall to link OCILIB shared library with language independence (default with prebuilt OCILIB libraries on MS Windows)
- Note:
- On Windows, OCI_API MUST be set to __stdcall in order to use prebuilt libraries
- Installing OCIB on UNIX like systems
OCILIB uses GNU tools for deployment and installation on UNIX like platforms
Uncompress the archive (ocilib-x.y.z-gnu.tar.gz)
- $ cd ocilib-x.y.z
- $ ./configure
- $ ./make
- $ ./make install (this step might require admin rights)
Check the shared library path environment variable (LD_LIBRARY_PATH, LD_PATH, ...):
- it must include $ORACLE_HOME\[lib|lib32|lib64]
- it must include the path where OCILIB has been installed (by example, typically /usr/local/lib under Linux)
In order to get theses values loaded at logon time, export theses values in your .profile configuration file :
- > export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib:/usr/local/lib
GNU Installation options :
OCILIB supports some options that are not needed for most common configurations.
List of available options:
- --with-oracle-import=(linkage|runtime)
- --with-oracle-charset=(ansi|unicode|mixed)
- --with-oracle-home=(custom oracle regular client directory)
- --with-oracle-lib64=(yes|no - check out folders on mixed 32/64bits platforms)
- --with-oracle-headers-path=(oracle header files directory)
- --with-oracle-lib-path=(oracle shared lib directory)
- --with-oracle-lib-name=(oracle shared lib name)
- --with-custom-loader=(linker flag telling the linker which loader to use when loading dynamically at runtime Oracle shared libs. This option must be provide if the platform does not use the default loader flag "-ldl") and the --with-oracle-import is set to 'runtime'
- Note:
- --with-oracle-headers-path and --with-oracle-lib-path are meant to be used with Instant client only but can used for regular client of libs and headers are not located in usual folders
If the Oracle OCI linkage mode is set to 'linkage' (default) and no Oracle lib path is provided, OCILIB configure script tries to located the Oracle library folder following this sequence :
- $ORACLE_HOME/lib32 (32 bits libs)
- $ORACLE_HOME/lib (32 or 64 bits libs)
- $ORACLE_HOME/lib64 (64 bits libs)
To compile native 64 bits versions of OCILIB, you need pass your compiler specifics flags to the configure script.
To use OCILIB in a project :
- include "ocilib.h" in your application
- Add the flag -I$USER_LIBS/include to your compiler
- Defines OCILIB modes :
- OCI import mode (-DOCI_IMPORT_LINKAGE or -DOCI_IMPORT_RUNTIME)
- OCI charset mode (-DOCI_CHARSET_ANSI, or DOCI_IMPORT_UNICODE or -DOCI_CHARSET_MIXED)
- Add the flag -L/$ORACLE_HOME/[lib|lib32|lib64] -lclntsh to the linker
- Add the flag -L$USER_LIBS/lib -locilib to the linker
where :
- $USER_LIBS is the folder where OCILIB was installed
- $ORACLE_LIB_PATH is Oracle client shared library path
Some older version of Oracle 8 have direct path symbols located in the library libclient8. So with theses versions, you must include as well the linker flag -lclient8 to use Direct Path API.
- Installing and using OCILIB on Microsoft Windows
32bits and 64bits DLLs are provided. Visual .NET (2005/2008) solutions are also provided to recompile the Dlls and the demo.
- Uncompress the archive (ocilib-x.y.z-windows.zip)
- Copy ocilib\include\ocilib.h to a folder listed in the compiler headers folders
- Copy ocilib[32|64][x].lib to a folder listed in the linker libraries folders
- Copy ocilib[32|64][x].dll to a folder included in the PATH environment variable
[x] is the compiled version of OCILIB ("a" -> ANSI, "w" -> Unicode, "m" -> Mixed)
To use OCILIB in a project :
- include "ocilib.h" in your application
- define OCILIB call convention (OCI_API) to __stdcall
- define OCILIB charset mode (OCI_CHARSET_ANSI | OCI_CHARSET_MIXED| OCI_CHARSET_UNICODE)
Note for MinGW users :
- Precompiled 32bits static libraries libocilib[x].a are provided
- To use OCILIB dll's, copy/rename import libraries ocilib[x].lib to libocilib[x].lib
- Add the desired version (static/shared + charset) of the library to the linker options
- Note:
- The OCI import mode (OCI_IMPORT_LINKAGE or OCI_IMPORT_RUNTIME is onbly used when compliing OCILIB source code
- Oracle Instant Client Support
OCILIB supports Oracle Instant Client.
On Microsoft Windows, there is no difference between using a regular Oracle client and an Instant Client with OCILIB
On Unix-like systems, the Instant Client is divided in different packages.
Public headers and shared libs are not part of the same package.
So, you must provide the following options to the configure command:
- with-oracle-headers-path: location the public header files
- with-oracle-lib-path: location the oracle shared lib
If your instant client package containing the shared libs does not have a symbolic link 'libclntsh.[shared lib extension]' to the fully qualified shared lib real name, you must create it:
Example on Linux:
- $ ln -s $ORALIBPATH/libclntsh.so.10.1 $ORALIBPATH/libclntsh.so
Generated on Thu Jul 30 17:41:53 2009 for OCILIB (C Driver for Oracle) by
1.5.4