LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 07-20-2023, 03:08 AM   #1
selfprogrammed
Member
 
Registered: Jan 2010
Location: Minnesota, USA
Distribution: Slackware 13.37, 14.2, 15.0
Posts: 638

Rep: Reputation: 155Reputation: 155
ldd falsely generates "not found" for valid library


I have been writing a dependency checker for slackware binaries.
It works, but is generating false detects because ldd is falsely outputting "not found".

The libraries that are not found all are shipped with the binary in their own lib directory. When one of the libraries in the dedicated lib directory references another in that same directory, ldd does not detect it.

It seems that ldd only find libraries that are in one of the common library directories.

Question: It has been said that shipping your binary with needed libraries in the same directory with the executable is supposed to work. Those libraries are supposed to be found first.

All my reading of dynamic linking order and reading ld man page cannot prove that.

I have packages that are seem to be doing exactly that, and they work.
They are the ones that ldd is falsely, not found.

I have checked by running the program and using lsof and fuser to see that the libraries that supposedly were "not found" were actually opened and were in use.

I am curious if others could report of the same behavior of ldd on their systems.
Is this systematic of ldd, or do I have some bad setup.
Please give evidence of your testing, not wild guessing.


Firefox
/usr/lib/firefox/libmozavcodec.so
- libmozavutil.so not found
(it is actually right there in the same directory)

seamonky
/usr/lib/seamonkey/libmozavcode.so
- libmozavutil.so not found
/usr/lib/seamonkey/libxul.so
- libldap60.so not found
- libprldap60.so not found
- libmozgtk.so not found
- liblgpllibs.so not found
- libmozsandbox.so not found
- libmozsqlite.so not found

wine
/usr/lib/wine/i386-unix/libxul.so
(same missing as in seamonkey)
/usr/lib/wine/i386-unix/bcrypt.so (and many others)
ntdll.so not found



quicktime
/usr/lib/libquicktime/lqt_x264.so
libx264.so.148 not found
(This one may be real, as I have /usr/lib/libx264.163)
 
Old 07-20-2023, 04:05 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,041

Rep: Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348
ldd uses the current environment to find libraries. check man ld.so to see how does it look for libraries and what environment variables are used.
 
Old 07-20-2023, 04:27 AM   #3
Dunc.
Member
 
Registered: Jul 2012
Location: Cumbria UK
Distribution: Slackware
Posts: 62

Rep: Reputation: 30
I thought I would try on my system and you're right I did get not found for firefox and seamonkey although mine are in lib64. I checked using ldconfig.
Code:
ldconfig -v | grep libmozavutil.so
This did not find them. So I added
Code:
/usr/lib64/firefox
/usr/lib64/seamonkey
to my /etc/ld.so.conf file. I checked ldconfig and ldd again and it resolved the issue. Now I feel that if I am going to put exceptions into ld.so.conf it should be in the directory /etc/ld.so.conf.d/ with files names firefox.conf and seamonkey.conf.
Since I did not notice any failures of firefox or seamonkey is this fixing a non fault. The software probably link the libraries at runtime so the output of ldd is not meaningful in that case. Keep looking because I don't know the answers to this.

Kind regards

Dunc.
 
Old 07-20-2023, 04:32 AM   #4
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,077

Rep: Reputation: Disabled
Mine is attached. Patrick Volkerding has also posted one he uses in LQ but I do not have a link at hand for his message.
Attached Files
File Type: txt deps_not_found.sh.txt (609 Bytes, 51 views)
 
2 members found this post helpful.
Old 07-20-2023, 04:51 AM   #5
henca
Senior Member
 
Registered: Aug 2007
Location: Linköping, Sweden
Distribution: Slackware
Posts: 1,012

Rep: Reputation: 678Reputation: 678Reputation: 678Reputation: 678Reputation: 678Reputation: 678
Quote:
Originally Posted by selfprogrammed View Post
The libraries that are not found all are shipped with the binary in their own lib directory. When one of the libraries in the dedicated lib directory references another in that same directory, ldd does not detect it.
ldd, like the dynamic linker searches, like others have said, in directories specified by /etc/ld.so.conf. It can also search in directories specified by the LD_LIBRARY_PATH environment variable.

Example:

Code:
bash-4.3$  ldd /usr/lib64/firefox-latest/libmozavcodec.so  | grep not
        libmozavutil.so => not found
bash-4.3$ export LD_LIBRARY_PATH=/usr/lib64/firefox-latest
bash-4.3$  ldd /usr/lib64/firefox-latest/libmozavcodec.so  | grep libmozavutil 
        libmozavutil.so => /usr/lib64/firefox-latest/libmozavutil.so (0x00007f6a184c7000)
Quote:
Originally Posted by selfprogrammed View Post
It seems that ldd only find libraries that are in one of the common library directories.
Yes, by default in only searches in "common" library directories, but the dynamic linker can be made to search in more directories.

Quote:
Originally Posted by selfprogrammed View Post
Question: It has been said that shipping your binary with needed libraries in the same directory with the executable is supposed to work. Those libraries are supposed to be found first.
This might be true, but it depends upon how the binary was linked when built. If linked with no special flags only "common" directories will be searched for dynamic libraries by the dynamic linker. However, if linked with the flag:

Code:
-Wl,-rpath='$ORIGIN'
the binary will search for dynamic libraries in the same directory as the binary lives in.

regards Henrik
 
2 members found this post helpful.
Old 07-20-2023, 07:17 AM   #6
solarfields
Senior Member
 
Registered: Feb 2006
Location: slackalaxy.com
Distribution: Slackware, CRUX
Posts: 1,456

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
FYI, you may get inspired by revdep and finddeps, found in CRUX, part of their prt-utils:

https://crux.nu/files/tools/prt-utils/
 
Old 07-20-2023, 09:40 AM   #7
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,077

Rep: Reputation: Disabled
Quote:
Originally Posted by solarfields View Post
FYI, you may get inspired by revdep and finddeps, found in CRUX, part of their prt-utils:

https://crux.nu/files/tools/prt-utils/
I had look at these tools and their man page and do not think that they can answer OP's question as they assume the existence of a ports or packages database that does not exist in Slackware in the same form.

PS As it happens I just installed CruxVoid in a VM today as they claim that the live ISO is now accessible with Braille and speech

Last edited by Didier Spaier; 07-21-2023 at 02:12 PM. Reason: I installled Void, not Crux...
 
Old 07-20-2023, 10:49 AM   #8
Petri Kaukasoina
Senior Member
 
Registered: Mar 2007
Posts: 1,938

Rep: Reputation: 1568Reputation: 1568Reputation: 1568Reputation: 1568Reputation: 1568Reputation: 1568Reputation: 1568Reputation: 1568Reputation: 1568Reputation: 1568Reputation: 1568
Quote:
Originally Posted by pan64 View Post
check man ld.so to see how does it look for libraries and what environment variables are used.
Quote:
Originally Posted by henca View Post
It can also search in directories specified by the LD_LIBRARY_PATH environment variable.
firefox etc set LD_LIBRARY_PATH. For example, if firefox is running, this command shows the values of the environment variables of all the children processes of the parent firefox:

Code:
ps --ppid "$(pgrep firefox)" eww
The environment variables seem to be in alphabetical order, so it's not so difficult to find LD_LIBRARY_PATH. But if you can't find it, this will find it for you:
Code:
ps --ppid "$(pgrep firefox)" eww|sed 's/.*\(LD_LIBRARY_PATH=[^ ]*\).*/\1/'
Quote:
Originally Posted by Dunc. View Post
I added
Code:
/usr/lib64/firefox
/usr/lib64/seamonkey
to my /etc/ld.so.conf file. I checked ldconfig and ldd again and it resolved the issue.
I'm not sure this is a good idea. The libraries in /usr/lib64/firefox are meant to be private to firefox. Package mozilla-nss exposes many libraries publicly (to other programs) in /usr/lib64 with same names (libfreeblpriv3.so libnspr4.so libnss3.so libnssckbi.so libnssutil3.so libplc4.so libplds4.so libsmime3.so libsoftokn3.so libssl3.so) as can also be found in /usr/lib64/firefox. If you have /usr/lib64 before /usr/lib64/firefox in ld.so.conf, I guess the correct one in /usr/lib64 is used, though.

Last edited by Petri Kaukasoina; 07-20-2023 at 10:52 AM.
 
3 members found this post helpful.
Old 07-20-2023, 11:24 AM   #9
solarfields
Senior Member
 
Registered: Feb 2006
Location: slackalaxy.com
Distribution: Slackware, CRUX
Posts: 1,456

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Quote:
Originally Posted by Didier Spaier View Post
I had look at these tools and their man page and do not think that they can answer OP's question as they assume the existence of a ports or packages database that does not exist in Slackware in the same form
ok.
 
Old 07-22-2023, 08:19 AM   #10
selfprogrammed
Member
 
Registered: Jan 2010
Location: Minnesota, USA
Distribution: Slackware 13.37, 14.2, 15.0
Posts: 638

Original Poster
Rep: Reputation: 155Reputation: 155
Just so you know,
I read that man page for ld.so and the man page for ld, ldconfig, etc., over and over again. They are not clear on anything except that they search some libraries specified by some environment variables,
and then the standard libraries.

I can find no sign of those environment variables, and they do not explain how what I described in the question would work.
LD_LIBRARY_PATH, saw that could not find where it was defined.
It is mentioned that the running program has this set.
But I have to find it without running the program.


I cannot go patching up ld cache for this. Also may cause problems (see Petri Kaukasoina post)
The programs work, it is only ldd that is not reporting correctly.

This still shows that ldd is weak and does NOT do all that is described.
It would need a switch that enabled it to look into the binary and extract that LD_LIBRARY_PATH, and check there too.

If this is only working because the program sets LD_LIBRARY_PATH using some system function, and then is using
dlopen to access the libraries, then I do not know what to do at this point.

I did a grep of the Firefox binary and did not find it.
Did a grep of the .mozilla directory, and it showed up in some saved restore point.
If it is in a different place for every program that might use it, a script has no reliable way to determine what they used.
I think it would be down to just assuming that any lib directory of that program is a probable target of LD_LIBRARY_PATH.
This is not correct, but might detect, or at least prevent false "not found" detections.

With look at that deps_not_found, as it sounds close to what I was writing.
Thank you.

Last edited by selfprogrammed; 07-22-2023 at 08:42 AM.
 
Old 07-22-2023, 08:36 AM   #11
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,041

Rep: Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348
actually I don't know how does firefox work, but usually they rely on the actual environment, especially on LD_LIBRARY_PATH and /etc/ld.so.conf. It was explained already on those man pages.
Additionally any app can load any .so file on the fly, based on its own implementation (see the man page of dlopen).
 
Old 07-22-2023, 08:45 AM   #12
Petri Kaukasoina
Senior Member
 
Registered: Mar 2007
Posts: 1,938

Rep: Reputation: 1568Reputation: 1568Reputation: 1568Reputation: 1568Reputation: 1568Reputation: 1568Reputation: 1568Reputation: 1568Reputation: 1568Reputation: 1568Reputation: 1568
removed

Last edited by Petri Kaukasoina; 07-22-2023 at 08:47 AM.
 
Old 07-22-2023, 08:50 AM   #13
ponce
LQ Guru
 
Registered: Aug 2004
Location: Pisa, Italy
Distribution: Slackware
Posts: 7,130

Rep: Reputation: 4202Reputation: 4202Reputation: 4202Reputation: 4202Reputation: 4202Reputation: 4202Reputation: 4202Reputation: 4202Reputation: 4202Reputation: 4202Reputation: 4202
I think the mozilla apps use rpath so that includes the current directory, as Henrik already noted.

for more info on rpath you can have a look, for example, at the wikipedia page.

Last edited by ponce; 07-22-2023 at 08:51 AM.
 
Old 07-22-2023, 09:08 AM   #14
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,160

Rep: Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266
The man page for ldconfig mentions the trusted directories: /lib, /usr/lib, /lib64 and /usr/lib64

The tools might not be looking in other directories without encouragement for security reasons.
 
Old 07-22-2023, 01:14 PM   #15
henca
Senior Member
 
Registered: Aug 2007
Location: Linköping, Sweden
Distribution: Slackware
Posts: 1,012

Rep: Reputation: 678Reputation: 678Reputation: 678Reputation: 678Reputation: 678Reputation: 678
Quote:
Originally Posted by selfprogrammed View Post
LD_LIBRARY_PATH, saw that could not find where it was defined.
By default, that environment variable is not defined at all. However, if any user chooses to set the LD_LIBRARY_PATH environment variable the dynamic linker will use the given paths to search for dynamic libraries.

Examples of where to set the LD_LIBRARY_PATH environment variable:
  • In some file below /etc/profile.d
  • In some login file in your home directory called by your shell. Depending upon your shell this might be .login, .profile, .cshrc or .bashrc.
  • In some script used to call a binary executable which needs some environment variables set before it is run.
  • Manually in the shell
    Code:
    export LD_LIBRARY_PATH=/my/special/dir:/some/more/stuff

regards Henrik
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Conky generates "sh: 1: skb: not found" on terminal (a lot!) PClOStinspace Linux - Software 7 03-26-2015 01:00 PM
ldd does not show the dependency library list sandy_linux Linux - Newbie 3 11-18-2010 02:11 AM
ldd reports shared library missing, but library exists on disk athv_gr Linux - Newbie 7 05-13-2009 12:31 PM
Ubuntu 5.10 -> 6.06: diversion of /usr/bin/ldd to /usr/bin/ldd.amd64 by ia32-libs HellSpawn Linux - Software 2 06-04-2006 09:18 PM
Why does my SuSE 10.0 media (eval DVD) check spontaneously (and falsely) fail? JavaGeekLover SUSE / openSUSE 2 03-06-2006 09:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 07:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration