ld.so system not working properly

Help with issues regarding installation of Debian

ld.so system not working properly

Postby kegon » 2020-02-12 21:29

Hi

Long time Debian user although not so familiar with all the system workings.

Following the problem I had with a fresh install of Buster here: viewtopic.php?f=17&t=145239, ld.so does not seem to be working correctly.
When writing an application, I keep the non-standard dependent libraries in a non-system directory (~/Application/lib) and I give this location as a library search path to the linker when compiling. I added this directory to my /etc/ld.so.conf file and re-ran ldconfig but one of the libraries is not picked up when I try to run my executable.

If I run ldd on my binary I get a line
Code: Select all
libmylib.so => not found


If I add the lib directory to my $LD_LIBRARY_PATH then the application can find the binary and works correctly.
If I run
Code: Select all
/sbin/ldconfig -p | grep mylib

I can see libmylib.so is found in my ~/Application/lib directory, as expected.

I suspect something about the ld.so system is running for root but not for users.

Any help appreciated. Thanks in advance.
kegon
 
Posts: 22
Joined: 2017-01-15 15:23

Re: ld.so system not working properly

Postby peter_irich » 2020-02-13 17:14

Try add your own *.conf with your string /etc/ld.so.conf.d/ and call ldconfig.

Peter.
peter_irich
 
Posts: 1269
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation

Re: ld.so system not working properly

Postby kegon » 2020-02-13 19:48

Hi Peter,

Thanks, I tried your tip but it didn't work.

I think that the ldconfig side is working because I can see that the path is added to the ld.so cache.
I think the runtime dynamic linker is not accessing it for some reason.
kegon
 
Posts: 22
Joined: 2017-01-15 15:23

Re: ld.so system not working properly

Postby Chrisdb » 2020-02-14 06:56

How did you add your directory to the '/etc/ld.so.conf' file?

I've had problems with the use of the '~' symbol. Try replacing it with:
Code: Select all
 /home/youruser/Application/lib


And then see what the output is of
Code: Select all
sudo ldconfig -v | grep '/home'
Chrisdb
 
Posts: 273
Joined: 2018-04-10 07:16

Re: ld.so system not working properly

Postby kegon » 2020-02-14 12:27

Hi Chris,

I have been using the full path.
Every time I have checked what is in the cache, I can see the full path too.

Thanks
kegon
 
Posts: 22
Joined: 2017-01-15 15:23

Re: ld.so system not working properly

Postby Chrisdb » 2020-02-14 14:31

You're not using an rpath for the library are you? Post output of:
Code: Select all
readelf -a libmylib.so
Chrisdb
 
Posts: 273
Joined: 2018-04-10 07:16

Re: ld.so system not working properly

Postby kegon » 2020-02-14 22:47

Hi Chris,

It's rather long:

Code: Select all
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              DYN (Shared object file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x1ba0
  Start of program headers:          64 (bytes into file)
  Start of section headers:          168096 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         8
  Size of section headers:           64 (bytes)
  Number of section headers:         38
  Section header string table index: 37


etc
kegon
 
Posts: 22
Joined: 2017-01-15 15:23

Re: ld.so system not working properly

Postby Chrisdb » 2020-02-15 06:22

My mistake, I meant run the command on your application(executable)

Try
Code: Select all
readelf <yourexecutable> -d | grep path
Chrisdb
 
Posts: 273
Joined: 2018-04-10 07:16

Re: ld.so system not working properly

Postby kegon » 2020-02-15 20:48

Here is the output from that command -

Code: Select all
$ readelf -a Application | grep path
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN:/home/kegon/Local/lib]


It has the correct path to the missing library.

Actually, the missing library is a dependency of a library that my application uses; I don't directly link to the missing lib but I did try adding it to the linked libraries anyway and it didn't help.
kegon
 
Posts: 22
Joined: 2017-01-15 15:23

Re: ld.so system not working properly

Postby peter_irich » 2020-02-16 06:10

Then check path in your *.conf in /etc/ld.so.conf.d.

Peter.
peter_irich
 
Posts: 1269
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation

Re: ld.so system not working properly

Postby Chrisdb » 2020-02-16 07:46

kegon wrote:When writing an application, I keep the non-standard dependent libraries in a non-system directory (~/Application/lib) and I give this location as a library search path to the linker when compiling. I added this directory to my /etc/ld.so.conf file and re-ran ldconfig but one of the libraries is not picked up when I try to run my executable


Strange, your executable's runpath points at
Code: Select all
/home/kegon/Local/lib


And not
Code: Select all
~/Application/lib
Chrisdb
 
Posts: 273
Joined: 2018-04-10 07:16

Re: ld.so system not working properly

Postby kegon » 2020-02-16 11:51

Sorry, I was trying to simplify things.

The ld.so.conf points at the correct directory.

I was trying to avoid a discussion about putting libs in /usr/local/lib because I am trying to keep my dependencies separate from other external application dependencies. I'm also using docker and AppImages, but not in this particular project.
kegon
 
Posts: 22
Joined: 2017-01-15 15:23

Re: ld.so system not working properly

Postby Chrisdb » 2020-02-16 12:41

Ok we really need more info

Post complete output of
Code: Select all
sudo ldconfig -v
ldd yourapplication
cat /etc/ld.so.conf (+ ld.so.conf.d dir)


Which compile command did you use ti create tour executable?
Chrisdb
 
Posts: 273
Joined: 2018-04-10 07:16

Re: ld.so system not working properly

Postby kegon » 2020-02-16 16:15

I'll try to give as much information as I can. The library I am trying to use is libdispatch which has a dependency on libkqueue.

Code: Select all
$ sudo ldconfig -v | grep "kqueue"
        libkqueue.so -> libkqueue.so.0

$ cat /etc/ld.so.conf
include /etc/ld.so.conf.d/*.conf
/home/kegon/Local/lib

$ ldd MyApplication | grep dispatch
        libdispatch.so.0 => /home/kegon/Local/lib/libdispatch.so.0 (0x00007f8bf4ad1000)

$ ldd MyApplication | grep kqueue
        libkqueue.so => /home/kegon/Local/lib/libkqueue.so (0x00007fc6abd68000)
        libkqueue.so.0 => not found

~/Local/lib$ ls -l | grep "kqueue"
-rwxr-xr-x 1 kegon kegon    170528 Jan 16  2019 libkqueue.so
lrwxrwxrwx 1 kegon kegon           Jan 16 11:02 libkqueue.so.0 -> libkqueue.so
lrwxrwxrwx 1 kegon kegon           Jan 16 11:02 libkqueue.so.0.0 -> libkqueue.so

$ ./MyApplication
./MyApplication: error while loading shared libraries: libkqueue.so.0: cannot open shared object file: No such file or directory


This application is using Qt and the generated Makefile is quite large but I can verify the following:

Code: Select all
LIBS          = -L/home/kegon/Local/lib -lkqueue -ldispatch -Wl,-rpath,/home/kegon/Local/lib
kegon
 
Posts: 22
Joined: 2017-01-15 15:23

Re: ld.so system not working properly

Postby Chrisdb » 2020-02-16 19:39

~/Local/lib$ ls -l | grep "kqueue"
-rwxr-xr-x 1 kegon kegon 170528 Jan 16 2019 libkqueue.so
lrwxrwxrwx 1 kegon kegon Jan 16 11:02 libkqueue.so.0 -> libkqueue.so
lrwxrwxrwx 1 kegon kegon Jan 16 11:02 libkqueue.so.0.0 -> libkqueue.so


The linking doesn't seem correct here.

Normally it should be something like this:
Code: Select all
libkqueue.so -> libkqueue.so.0
libkqueue.so.0 -> libkqueue.so.0.0


Where did you get this lib?
Chrisdb
 
Posts: 273
Joined: 2018-04-10 07:16

Next

Return to Installation

Who is online

Users browsing this forum: No registered users and 10 guests

fashionable