Josh Benson
Josh Benson

Reputation: 236

Shared libraries not found but in ld.so.conf path

I am trying to install Cracklib 2.9.6 from source so that I can build Shadow against it, but I am running into a problem when trying to build the dictionaries and install them.

/sources/cracklib-2.9.6$ create-cracklib-dict /usr/share/dict/cracklib-words \
/usr/share/dict/cracklib-extra-words
cracklib-packer: error while loading shared libraries: libcrack.so.2:
cannot open shared object file: No such file or directory

The shared libraries are installed in /lib:

/sources/cracklib-2.9.6$ ls /lib/libcrack*
/lib/libcrack.so.2  /lib/libcrack.so.2.9.0

There are symbolic links in /usr/lib to the real libraries in /lib:

/sources/cracklib-2.9.6$ ls -al /usr/lib/libcrack*
-rwxr-xr-x 1 root root 913 Jul 17 22:06 /usr/lib/libcrack.la
lrwxrwxrwx 1 root root  27 Jul 17 22:06 /usr/lib/libcrack.so -> ../../lib    /libcrack.so.2.9.0
lrwxrwxrwx 1 root root  23 Jul 17 22:28 /usr/lib/libcrack.so.2 -> ../../lib/libcrack.so.2

The last symbolic link is one I created myself to try and solve this problem, in case create-cracklib-dict was only looking in /usr/lib for the shared library. I do not know why create-cracklib-dict is not finding them. I have used a similar install method for several other libraries compiled from source and have had no issues.

EDIT: I am now having the same problem with bunzip2. If I use LD_PRELOAD=/lib/libbz2.so.1.0 /bin/bunzip2, then the program works. Here's my /etc/ld.so.conf:

# Begin /etc/ld.so.conf
/usr/local/lib
/opt/lib
/lib

# Add an include directory
include /etc/ld.so.conf.d/*.conf

Running ldd -p shows that the /lib directory is within the path searched by ld. Here is the output from ldconfig -v

/sources/XML-Parser-2.44$ cat ldconfig.log
/usr/local/lib:
/lib:
    libdl.so.2 -> libdl-2.23.so
    libSegFault.so -> libSegFault.so
    libpcprofile.so -> libpcprofile.so
    libz.so.1 -> libz.so.1.2.8
    libcom_err.so.2 -> libcom_err.so.2.1
    libmemusage.so -> libmemusage.so
    libe2p.so.2 -> libe2p.so.2.3
    libc.so.6 -> libc-2.23.so
    libcidn.so.1 -> libcidn-2.23.so
    libcrypt.so.1 -> libcrypt-2.23.so
    libnss_files.so.2 -> libnss_files-2.23.so
    libnsl.so.1 -> libnsl-2.23.so
    libm.so.6 -> libm-2.23.so
    librt.so.1 -> librt-2.23.so
    libnss_hesiod.so.2 -> libnss_hesiod-2.23.so
    libpthread.so.0 -> libpthread-2.23.so
    libutil.so.1 -> libutil-2.23.so
    ld-linux.so.2 -> ld-2.23.so
    libresolv.so.2 -> libresolv-2.23.so
    libncursesw.so.6 -> libncursesw.so.6.0
    libnss_db.so.2 -> libnss_db-2.23.so
    libss.so.2 -> libss.so.2.0
    libreadline.so.6 -> libreadline.so.6.3
    libBrokenLocale.so.1 -> libBrokenLocale-2.23.so
    libcap.so.2 -> libcap.so.2.25
    libnss_nis.so.2 -> libnss_nis-2.23.so
    libnss_compat.so.2 -> libnss_compat-2.23.so
    libattr.so.1 -> libattr.so.1.1.0
    libprocps.so.5 -> libprocps.so.5.0.0
    libanl.so.1 -> libanl-2.23.so
    libacl.so.1 -> libacl.so.1.1.0
    libcrack.so.2 -> libcrack.so.2.9.0
    libext2fs.so.2 -> libext2fs.so.2.4
    libbz2.so.1.0 -> libbz2.so.1.0.6
    libnss_dns.so.2 -> libnss_dns-2.23.so
    libhistory.so.6 -> libhistory.so.6.3
    libnss_nisplus.so.2 -> libnss_nisplus-2.23.so
    libthread_db.so.1 -> libthread_db-1.0.so
/usr/lib:
    libssp.so.0 -> libssp.so.0.0.0
    libubsan.so.0 -> libubsan.so.0.0.0
    libgcc_s.so.1 -> libgcc_s.so.1
    libmpfr.so.4 -> libmpfr.so.4.1.3
    libltdl.so.7 -> libltdl.so.7.3.1
    libgdbm.so.4 -> libgdbm.so.4.0.0
    libmenuw.so.6 -> libmenuw.so.6.0
    libformw.so.6 -> libformw.so.6.0
    libasan.so.2 -> libasan.so.2.0.0
    libexpat.so.1 -> libexpat.so.1.6.0
    libquadmath.so.0 -> libquadmath.so.0.0.0
    libgmp.so.10 -> libgmp.so.10.3.0
    libgdbm_compat.so.4 -> libgdbm_compat.so.4.0.0
    libfl.so.2 -> libfl.so.2.0.0
    libitm.so.1 -> libitm.so.1.0.0
    libopcodes-2.26.20160125.so -> libopcodes.so
    libgomp-plugin-host_nonshm.so.1 -> libgomp-plugin-host_nonshm.so.1.0.0
    libcilkrts.so.5 -> libcilkrts.so.5.0.0
    libatomic.so.1 -> libatomic.so.1.1.0
    libgmpxx.so.4 -> libgmpxx.so.4.5.0
    libvtv.so.0 -> libvtv.so.0.0.0
    libmagic.so.1 -> libmagic.so.1.0.0
    libcc1.so.0 -> libcc1.so.0.0.0
    libstdc++.so.6 -> libstdc++.so.6.0.21
    libbfd-2.26.20160125.so -> libbfd.so
    libmpc.so.3 -> libmpc.so.3.0.0
    libgomp.so.1 -> libgomp.so.1.0.0
    libfl_pic.so.2 -> libfl_pic.so.2.0.0
    libpanelw.so.6 -> libpanelw.so.6.0

Something interesting happened when I invoked ldconfig -v though, I got the following message:

/sources/XML-Parser-2.44$ ldconfig -v > ldconfig.log
ldconfig: Path `/lib' given more than once
ldconfig: Path `/usr/lib' given more than once

Running ldd -d -r /bin/bunzip2 results in the following:

/sources/XML-Parser-2.44$ ldd -d -r /bin/bunzip2
    linux-gate.so.1 (0xb77bc000)
    libbz2.so.1.0 => not found
    libc.so.6 => /tools/lib/libc.so.6 (0xb7608000)
    /tools/lib/ld-linux.so.2 (0xb77bd000)
undefined symbol: BZ2_bzlibVersion  (/bin/bunzip2)
undefined symbol: BZ2_bzReadClose   (/bin/bunzip2)
undefined symbol: BZ2_bzWriteOpen   (/bin/bunzip2)
undefined symbol: BZ2_bzWrite   (/bin/bunzip2)
undefined symbol: BZ2_bzReadGetUnused   (/bin/bunzip2)
undefined symbol: BZ2_bzWriteClose64    (/bin/bunzip2)
undefined symbol: BZ2_bzReadOpen    (/bin/bunzip2)
undefined symbol: BZ2_bzRead    (/bin/bunzip2)

Upvotes: 1

Views: 3583

Answers (2)

Josh Benson
Josh Benson

Reputation: 236

The problem ended up being an issue with my compiler-linker toolchain. The specs file gcc was using to compile all the libraries in question was pointing to an older version of ld located in the /tools/ directory. Readjusting the specs file per the instructions here resulted in gcc producing binaries that compiled against the correct linker and called on the correct dynamic library loader that was able to search /lib and /usr/lib and find the libraries. In other words, be very careful when adjusting the gcc specs file!

Upvotes: 1

Asrail
Asrail

Reputation: 146

After placing new files into the ld.so search path, you must run ldconfig to update the cache.

See the ldconfig manpage for the reference: http://linux.die.net/man/8/ldconfig

Upvotes: 1

Related Questions