C language development process, need to operate the database, use Oracle database generally will use Oracle Pro*C/C++ precompiler.

This article introduces the Oracle Pro*C/C++ precompiler in detail, learns its role in developing applications that manipulate Oracle data, and learns what it enables your applications to do. Specific as use.

This chapter describes how to install the Oracle Pro*C/C++ Compact client compilation environment.


Client Installation

Oracle Instant Client Basic provides the TNS service name configuration function.

The Instant Client is available in two versions: Basic and Basic Lite.

  • The Basic version includes all the files that support running OCI, OCCI, JDBC, jDBC-OCI, and supports multiple languages.
  • Basic Lite is a stripped-down version of Basic that includes only English error descriptions and only supports Unicode, ASCII, and The European character set.

If the database server is a Chinese character set (such as SIMPLIFIED Chinese_china.zhs16GBk), you must download the Basic version.

This article uses instantclient-basic-linux.x64-19.11.0.0.0dbru.zip

Build environment Installation

To be able to use the Oracle proc/C ++ Precompiler, you need to download an additional Precompiler Package that provides additional tools and libraries for the ProC and Pro*COBOL precompilers.

This article uses instantclient-precomp-linux.x64-19.11.0.0.0dbru.zip

To compile properly, you need to download the SDK package, which contains additional header files and a sample Makefile.

This article uses instantclient-SDK-linux.x64-19.11.0.0.0 dbru.zip

Installation method

Create user from root
useradd study  
# Switch user
su - study
Unzip the installation packageUnzip instantClient-basic-linux.x64-19.11.0.0.0 dbru. Zip Unzip instantclient-precomp-linux.x64-19.11.0.0.0dbru. Zip unzip Instantclient-precomp-linux.x64-19.11.0.0.0 dbru Instantclient - SDK - Linux. X64-19.11.0.0.0 dbru. ZipAdd environment variables
vi .bash_profile
Add the following environment variables
export ORACLE_HOME=/home/study/instantclient_19_11
export TNS_ADMIN=/home/study/instantclient_19_11
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export LD_LIBRARY_PATH=/home/study/instantclient_19_11
Copy the code

The installation directory

When you install the Oracle Lite client, a directory structure is created for Oracle products on your hard drive.

The Oracle home directory contains the Oracle subdirectories and files needed to run Pro*C/C++.

$ORACLE_HOME This directory contains the Pro*C/C++ executables, library files, and sample programs listed in the table.

Directory name content
/precomp/admin The configuration file
/sdk/demo Pro*C/C++ example procedures
/sdk/include The header file

Compile the verification

# Override environment variables
source $HOME/.bash_profile
# Test the compiler
cd $HOME/instantclient_19_11/sdk/demo
make -f demo_proc_ic.mk
Copy the code