Skip to content
Advertisement

Startup program and libocci.so.11.1: cannot open shared object file: No such file or directory

please any one save my time .my application is written in c++ I was try to startup on boot in ubuntu linux,but when the program try to start it log error like:- error while loading shared libraries: libocci.so.11.1: cannot open shared object file: No such file or directory my program use oracle api:- my start service script which is written in /etc/init.d/sistartup:-

#!/bin/sh
# chkconfig: 345 99 10
OWNER=aki

case "$1" in
    'start')
        su $OWNER -c "/home/aki/sis_script/startsis.sh >> /home/aki/sis_script/sistartup.log 2>&1" &
       # touch /var/lock/subsys/sis_engine
        ;;
esac

startup script which is written on appropriate user is:- /home/aki/script/startsis.sh

  #!/bin/bash
    export TMP=/tmp
    export TMPDIR=$TMP
    export PATH=/usr/sbin:/usr/local/bin:$PATH
    # Start db_test
    ./home/aki/summ/db_test

My c++ sample test_db.cpp application write below:-

    #include <iostream>
    #include <occi.h>
    #include <string>
    using namespace oracle::occi;
    using namespace std;
    Environment *env;
    Connection  *con;
    int main(){

            string user;
            string passwd;
            string db;
            user ="sis";
            passwd = "sis10";
            db = "localhost:1521/sisdba";
            env = Environment::createEnvironment((Environment::Mode)(Environment::OBJECT|Environment::THREADED_MUTEXED));
                    con = env->createConnection(user, passwd, db);
                    while(1){
                        cout<<"Here i have some business which is related to oracle database "<<endl;
                    }
                    return 0;
}

After compiling the file in this way

g++ -o db_test test_db.cpp -I$ORACLE_HOME/rdbms/public -L$ORACLE_HOME/lib -locci -lclntsh

I see this error :- error while loading shared libraries: libocci.so.11.1: cannot open shared object file: No such file or directory

Advertisement

Answer

If you have to provide -L$ORACLE_HOME/lib on the build command line, that suggests to me that the libraries aren’t in any of the system’s library paths, so they won’t be found automatically at runtime.

You can confirm this theory by setting LD_LIBRARY_PATH=$ORACLE_HOME/lib before running your program; it should then work. However, depending on your requirements, this may be only worth a temporary workaround (and I’m assuming the $ORACLE_HOME is available!). A more long-term fix might be to add this path to /etc/ld.so.conf, though this then will affect all executables on your system.

Ultimately, you should follow the installation instructions for the library.

Advertisement