简体   繁体   中英

error while loading shared libraries: libclntsh.so.11.1: cannot open shared object file: No such file or directory

I'm making a C program which is connecting a oracle DB. I have correctly installed the Oracle Instant Client and ocilib.

And I did compile the code without any error but when I executing the program I got following error.

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

If anyone know how to solve please write it Thank you.

Yes I solve it by adding a link of the library to the /usr/lib .

using the following command.

sudo ln -s /home/INSTANT_CLIENT/lib/libclntsh.so.11.1 /usr/lib/libclntsh.so.11.1

Make sure the Examples CD is installed. Make sure environment variable LD_LIBRARY_PATH is set, and the library file is accessible (permission-wise) for the user who you are logged in as.

If you have checked these and still get the error, please post the output of: strace ./a.out

LIBPATH environment variable should be pointed to the lib32 folder which contains the libclntsh.

then you need to export LIBPATH variable before you run your application.

Copied from my answer here: Eclipse CDT Auto Include Shared Libraries

Run ldconfig as root to update the cache - if that still doesn't help, you need to add the path to the file ld.so.conf (just type it in on its own line) or better yet, add the entry to a new file (easier to delete) in directory ld.so.conf.d.

您需要设置 LD_LIBRARY export LD_LIBRARY_PATH=/path/instantclient:$LD_LIBRARY_PATH 就像 export LD_LIBRARY_PATH=/oracle/instantclient_21_4:$LD_LIBRARY_PATH

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM