1

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

jww
  • 97,681
  • 90
  • 411
  • 885
Sisay Zinabu
  • 71
  • 2
  • 14
  • When you compile your `test_db.cpp` program, add an RPATH with `$ORACLE_HOME/lib` so the system can find your libs. Maybe better, copy everything into `/opt/test_db`, make it wold readable, and then use `/opt/test_db` as the RPATH. Also see [How to specify rpath in a make file?](http://stackoverflow.com/q/6638500/608639) and [I don't understand -Wl,-rpath](http://stackoverflow.com/q/6562403/608639). – jww Apr 07 '17 at 09:41

2 Answers2

1

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.

Community
  • 1
  • 1
Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
  • Thank you for your response – Sisay Zinabu Apr 06 '17 at 09:44
  • :-Thank you for your response.If you have idea about oracle every oracle library have oracle user privilege.so when my startup script start on boot it is start on root user so root doesn't have access privilege on each oracle library.Therefore this issue is related to privilege of accessing oracle library please if you have idea about it help me.Thanks in advance – Sisay Zinabu Apr 06 '17 at 09:56
  • The root user has complete privileges to everything on the system. – Lightness Races in Orbit Apr 06 '17 at 10:01
  • you are right,but in oracle installation oracle component not recommended to have root privilege. – Sisay Zinabu Apr 06 '17 at 13:53
  • @SisayZinabu: Then why are you running it as root? Either you want it to run as root, or you don't? Shouldn't really matter either way. – Lightness Races in Orbit Apr 06 '17 at 16:56
0

did libocci.so.11.1 successfully installed?

shulianghe
  • 94
  • 1
  • 3
  • Thanks for your response. libocci.so.11.1 is oracle library to use in c++ code,but this library own only oracle user not root user .When my startup service start it may be run in root privilege – Sisay Zinabu Apr 06 '17 at 09:36