Saagar
Saagar

Reputation: 29

./a.out: error while loading shared libraries: libocilib.so.3: cannot open shared object file: No such file or directory

Below is my simple test code. I have compile it using

      $gcc test.c -DOCI_IMPORT_LINKAGE -DOCI_CHARSET_ANSI -locilib

It compile successfully but when i run it it show error-

     ./a.out: error while loading shared libraries: libocilib.so.3: cannot open shared object file: No such file or directory

I have added below path to my bashrc file -

       export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client/lib
       export ORACLE_HOME=/usr/lib/oracle/11.2/client
       export TNS_ADMIN=/usr/lib/oracle/11.2/client/network/admin

#include "ocilib.h"

int main(void)
{
    OCI_Connection *cn;

    if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT))
        return EXIT_FAILURE;

   cn = OCI_ConnectionCreate("sam", "SYSTEM", "oracle", OCI_SESSION_DEFAULT);

   printf("Server major    version : %i\n",   OCI_GetServerMajorVersion(cn));
   printf("Server minor    version : %i\n",   OCI_GetServerMinorVersion(cn));
   printf("Server revision version : %i\n\n", OCI_GetServerRevisionVersion(cn));
   printf("Connection      version : %i\n\n", OCI_GetVersionConnection(cn));

   OCI_Cleanup();

   return EXIT_SUCCESS;

}

i don't know what's the reason. please help. I know little bit about linux.

Upvotes: 0

Views: 2030

Answers (2)

Jorge Sanabria
Jorge Sanabria

Reputation: 71

Can also work by typing when compiling: "-static":

gcc -static test.c -DOCI_IMPORT_LINKAGE -DOCI_CHARSET_ANSI -locilib

and run the program normally:

./a.out

Upvotes: 0

Vincent Rogier
Vincent Rogier

Reputation: 121

The OCILIB shared library folder is not in your LD_LIBRARY_PATH variable....

Upvotes: 2

Related Questions