Search code examples
oracle-databasevisual-c++visual-studio-2017oracle-sqldeveloperocci

How to get Oracle C++ Call interface (OCCI) working on Visual Studio?


I'm learning and using oracle with SQL. I've created a database with OracleSQLDeveloper and now I'm trying to have access within a project writed in C++.

I've been searching and I've found that Oracle has Oracle C++ Call Interface (OCCI) and using this I can achieve what I want.

My question is, somone know's what exactly do I need to do to get OCCI working on Visual Studio? I can't get it working at all and I've spend so much time.

Hope somone can help me, thanks!

PD: Sorry for my english :)


Solution

  • Below is the compilation script for OCCI application on Linux machine it will be more or less same on windows.

    g++ someSourceFiles.cpp -o out -I$INC_DIR -I$ORACLE_HOME/lib -I$ORACLE_HOME/precomp/public -I$ORACLE_HOME/rdbms/public -L$ORACLE_HOME/lib -locci -lclntsh -lnnz12 -lons -lclntshcore
    

    Here $ORACLE_HOME is a environment variable mostly set in PATH variable if you are using Windows and bash_profile if you are using Linux.

    Normally it points to the ORACLE home directory

    Below two points to the paths where header files required for OCCI implementation are present.

    -I$ORACLE_HOME/precomp/public 
    -I$ORACLE_HOME/rdbms/public 
    

    Below are dynamically linked shared libraries required to access OCCI methods

    -locci -lclntsh -lnnz12 -lons -lclntshcore
    

    Below is the path where shared libraries are present.

    -L$ORACLE_HOME/lib
    

    Now your are trying to implement these on Visual studio you need to configure above explained variables in your project settings in visual studio to compile them.

    NOTE: In your case shared libraries will be of .dll form as it is windows.