Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

ld.so system not working properly

Ask for help with issues regarding the Installations of the Debian O/S.
Post Reply
Message
Author
kegon
Posts: 22
Joined: 2017-01-15 15:23

ld.so system not working properly

#1 Post by kegon »

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: http://forums.debian.net/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.

peter_irich
Posts: 1403
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation
Been thanked: 11 times

Re: ld.so system not working properly

#2 Post by peter_irich »

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

Peter.

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

Re: ld.so system not working properly

#3 Post by kegon »

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.

Chrisdb
Posts: 279
Joined: 2018-04-10 07:16

Re: ld.so system not working properly

#4 Post by Chrisdb »

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'

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

Re: ld.so system not working properly

#5 Post by kegon »

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

Chrisdb
Posts: 279
Joined: 2018-04-10 07:16

Re: ld.so system not working properly

#6 Post by Chrisdb »

You're not using an rpath for the library are you? Post output of:

Code: Select all

readelf -a libmylib.so

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

Re: ld.so system not working properly

#7 Post by kegon »

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

Chrisdb
Posts: 279
Joined: 2018-04-10 07:16

Re: ld.so system not working properly

#8 Post by Chrisdb »

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

Try

Code: Select all

readelf <yourexecutable> -d | grep path

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

Re: ld.so system not working properly

#9 Post by kegon »

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.

peter_irich
Posts: 1403
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation
Been thanked: 11 times

Re: ld.so system not working properly

#10 Post by peter_irich »

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

Peter.

Chrisdb
Posts: 279
Joined: 2018-04-10 07:16

Re: ld.so system not working properly

#11 Post by Chrisdb »

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

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

Re: ld.so system not working properly

#12 Post by kegon »

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.

Chrisdb
Posts: 279
Joined: 2018-04-10 07:16

Re: ld.so system not working properly

#13 Post by Chrisdb »

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?

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

Re: ld.so system not working properly

#14 Post by kegon »

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 

Chrisdb
Posts: 279
Joined: 2018-04-10 07:16

Re: ld.so system not working properly

#15 Post by Chrisdb »

~/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?

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

Re: ld.so system not working properly

#16 Post by kegon »

I did the symlinking. As I understand it, linking doesn't matter as long as the absolute path resolves to the correct .so and the version numbering is also correct. I have used this type of linking before and never had any problems with it.

For thoroughness, I redid the linking in the way you describe and relinked the binary but it didn't help.

I took the binary elements of these libraries from what is now a deprecated package from Jessie. I had previously used on Sid, Jessie and then Stretch.

Refs:
https://packages.debian.org/search?keywords=libdispatch
https://github.com/mheily/libkqueue
https://github.com/apple/swift-corelibs-libdispatch

Chrisdb
Posts: 279
Joined: 2018-04-10 07:16

Re: ld.so system not working properly

#17 Post by Chrisdb »

What's the output now of

Code: Select all

ls -l | grep "kqueue"
And

Code: Select all

file libkqueue.so.0.0
Since you compiled the executable with rpath, it won't make Any difference if you pass the lib directory to 'lo.so.conf'

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

Re: ld.so system not working properly

#18 Post by kegon »

@Chrisdb

Code: Select all

$ ls -l libkq*
-rwxr-xr-x 1 kegon kegon 170528 Jan 16  2019 libkqueue.so
lrwxrwxrwx 1 kegon kegon     12 Feb 17 19:22 libkqueue.so.0 -> libkqueue.so
lrwxrwxrwx 1 kegon kegon     14 Feb 16 22:33 libkqueue.so.0.0 -> libkqueue.so.0

$ file libkqueue.so
libkqueue.so: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=9328028820c04741832ec8d74df282e965d4de03, with debug_info, not stripped
I guess this ^ is the problem - it's seen as a SYSV PIE executable. I'm sure I was using this library's binary before; I wouldn't have renamed some executable to be a library. Probably something in the kernel changed when I moved to Buster and previously some compatibility thing kept the old version working until then. Seeing as though I have source, I will have to try to compile my own.

Thanks for all the help.

If I'm right, it's been interesting to learn that ldconfig did some kind of check that libraries are in fact shared objects.

Post Reply