cannot open shared object file: No such file or directory
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
testuser@testuser-desktop:~$ cd Documents/c_files/
testuser@testuser-desktop:~/Documents/c_files$ ls
a.out findL.c libprint_test.so open_dll
atoi.c findlist.c ListHandle.txt opendll.c
change_directory.c find_List.c listoffiles22.c opendll.o
check_f_d.c findLUn.c list_with_count.c open_dll.so
chg_f_d.c itoa.c main_chk.c open_lib.c
chk_finL.c libacl.so.1.1.0 my_folder vinayteja.c
code_for_fin.c libopendll.so my_itoa.c
files_in_cwd.c libopen_lib.so opendll
testuser@testuser-desktop:~/Documents/c_files$ gcc opendll.c -ldl
testuser@testuser-desktop:~/Documents/c_files$ ./a.out
entered into main
libprint_test.so: cannot open shared object file: No such file or directorytestuser@testuser-desktop:~/Documents/c_files$ export LD_LIBRARY_PATH=`pwd`
testuser@testuser-desktop:~/Documents/c_files$ ./a.out
entered into main
/home/testuser/Documents/c_files/libprint_test.so: undefined symbol: tempcannot open the handle
testuser@testuser-desktop:~/Documents/c_files$
Questions.
1.i would like to ask why should we use export LD_LIBRARY_PATH.
2.why is that it is not detecting the libprint_test.so
3.i repeated the same test with with open_dll.so, its working fine, why?
Code:
testuser@testuser-desktop:~/Documents/c_files$ gcc opendll.c -ldl
testuser@testuser-desktop:~/Documents/c_files$ ./a.out
entered into main
entered in to lib jzkgcvkzjvhkdjvhjk********
thank you for listening.
thanks a ton in advance for answering.
By default, when LD_LIBRARY_PATH is not set, dlopen() searches for simple names (those without a '/' character) in the libraries cached in the file /etc/ld.so.cache, as found by the "ldconfig" command (usually executed when libraries are changed by package updates). If LD_LIBRARY_PATH is set with one or more colon separated directory path names, those directories are searched earlier (as long as this executable is not flagged as setuid/setgid). See the man page for dlopen for the exact description.
If the file to be opened will always be in the current directory, you could change the code like this (delete the line prefixed by '-' and insert the line prefixed by '+'):
and this would skip the search and just go straight to the specified file. A more permanent approach for an in-production program would be to place that .so file in a library directory and add it to the config(s) read by the "ldconfig" command (usually /etc/ld.so.conf and often separate files in /etc/ld.so.conf.d).
The first thing that I would do, either as root or via sudo, is to execute the ldconfig command.
Background: When a program requests the use of a library, the program can be as specific ("I want mylib.1.3.0") or as generic ("I want mylib," the latest version, please, as long as it's at least version 1") as it wishes to be. So, the first step in debugging is to determine which versions the program is actually requiring, and do qualifying versions actually exist. (The loader thinks that they don't.)
The next step is the loader-cache, hence "ldconfig." The loader constructs a cache-file to tell it exactly where the various libraries are located, so that it doesn't have to perform a filesystem search for each one. ldconfig reconstructs this cache. Although package installers usually re-execute this command for you, they might not. If the requested library is not in the cache, it won't be found, even if it exists in the file system.
Last edited by sundialsvcs; 07-01-2011 at 08:40 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.