Using Oracle Instant Client
You can build C/C++ applications that use Oracle Instant Client and connect to an Oracle AI Database server. If you want to build a 64-bit application and use sdk/demo/demo.mk file, then perform the following steps:
Edit the
sdk/demo/demo.mkfile and set:CCvariable to yourg++locationccvariable to yourgcclocationICLIBHOMEvariable to the path to the installed Instant Client libraries. For example, if the libraries are located in/home/oracle/OTN/instantclient_23_26/, then set:ICLIBHOME=/home/oracle/OTN/instantclient_23_26/ICINCHOMEvariable to$(ICLIBHOME)/sdk/directoryCCINCLUDESvariable to the location(s) of your application's header files. For example, if your application's header files reside in/home/app_headersdirectory, then set:CCINCLUDES=-I$(ICINCHOME)include -I/home/app_headers/CCFLAGSvariable to your application's other compile options.The recommended compilation options are as follows:-DMAC_AARCH64 -D_GNU_SOURCE -D_REENTRANT -g -arch arm64 -mcpu=apple-m1 -I$(ICINCHOME)includeRun
make -f demo.mk buildoci EXE=cdemo81 OBJS=cdemo81.ofor a working demonstration of the recommended options.CCLIBvariable to the libraries your application depends on and their location. For example, if your application depends on/home/app_libs/libA.so, then add-L/home/app_libs -lAtoCCLIB.LDFLAGSvariable to your application's other link options. The recommended link options are as follows:-arch arm64 -L$(ICLIBHOME) -locci -lclntsh -lpthreadRun
make -f demo.mk buildoci EXE=cdemo81 OBJS=cdemo81.ofor a working demonstration of the recommended options.
- Compile your C/C++ application by running
make -f demo.mk buildocci EXE=exename OBJS= list_of_dependent_objects. Set
JAVA_PATHin theottscript to the location oflibocijdbc23.dylib, if you notice the following issue while building your C++ application:Exception in thread "main" java.lang.UnsatisfiedLinkError: no ocijdbc23 in java.library.path JAVA_PATH=-Djava.library.path=location_of_libocijdbc23If your application has not been compiled with
rpaths, update theDYLD_LIBRARY_PATHenvironment variable with the list of directories containing the libraries your application depends on. For example:export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:/home/oracle/OTN/instantclient_23_26/:/home/app_headers/- If you intend to colocate the optional Oracle configuration files such as
tnsnames.orawith the Oracle Instant Client, then move these files to thenetwork/adminsubdirectory. This is the default Oracle configuration directory for applications linked with this Oracle Instant Client. Alternatively, you can move the Oracle configuration files to another, accessible directory. Then set the environment variableTNS_ADMINto that directory name. To use binaries such as
sqlplusfrom theSQL*Pluspackage or any other Oracle Instant Client package, update yourPATHenvironment variable. For example:PATH=$PATH:/home/oracle/OTN/instantclient_23_26/
Related Topics
Configuring Pro*C/C++
Verify that the PATH environment variable setting includes the directory that contains the C compiler executable. The default directory for the gcc compiler executable is /usr/bin.
Note:
To suppress ISO C99 Errors/Warnings, use the option -Wno-error= or --std=gnu89 while compiling C programs. Always include stdio.h before stdlib.h in pc programs.
Related Topics