Bookmark this page

Guided Exercise: Resolving Library Dependencies

Install third-party software and resolve library dependencies.

Outcomes

You should be able to identify which libraries an application requires to run on a system.

As the student user on the workstation machine, use the lab command to prepare your system for this exercise.

[student@workstation ~]$ lab start application-dependencies

This command confirms that the required hosts for this exercise are accessible and installs the application package.

Instructions

Another system administrator installed the genisoimage application and cannot run it. You are asked to solve the issue.

  1. Log in as student on servera. Attempt to execute the newly installed program, and observe how it behaves. An error message is displayed. The program generates the same error message when failing to resolve a library as when the shell cannot locate a command.

    [student@workstation ~]$ ssh student@servera
    ...output omitted...
    [student@servera ~]$ genisoimage
    genisoimage: error while loading shared libraries: libusal.so.0: cannot open shared object file: No such file or directory
    [student@servera ~]$ echo $?
    127
  2. Determine which shared libraries the program requires. The error message states that libusal.so.0 is required, but that other required libraries might also be missing. All but two libraries are resolved: libusal.so.0 and librols.so.0.

    [student@servera ~]$ which genisoimage
    /usr/bin/genisoimage
    [student@servera ~]$ ldd /usr/bin/genisoimage
    	linux-vdso.so.1 (0x00007ffe333e9000)
    	libmagic.so.1 => /lib64/libmagic.so.1 (0x00007fab7d738000)
    	libc.so.6 => /lib64/libc.so.6 (0x00007fab7d373000)
    	libz.so.1 => /lib64/libz.so.1 (0x00007fab7d15c000)
    	libbz2.so.1 => /lib64/libbz2.so.1 (0x00007fab7cf4b000)
    	libusal.so.0 => not found
    	librols.so.0 => not found
    ...output omitted...
  3. Locate the packages that provide those two libraries.

    [student@servera ~]$ yum provides libusal.so.0
    libusal-1.1.11-39.el8.i686 : Library to communicate with SCSI devices
    Repo        : rhel-8.4-for-x86_64-appstream-rpms
    Matched from:
    Provide    : libusal.so.0
    [student@servera ~]$ yum provides librols.so.0
    libusal-1.1.11-39.el8.i686 : Library to communicate with SCSI devices
    Repo        : rhel-8.4-for-x86_64-appstream-rpms
    Matched from:
    Provide    : librols.so.0
  4. The libusal package provides both libraries. Use the sudo command to run yum to install it. Use student as the password if prompted.

    [student@servera ~]$ sudo yum install libusal
    [sudo] password for student: student
    ...output omitted...
  5. As the student user, attempt to run the original program again.

    The executable appears to run, but displays a new message because of invalid arguments.

    [student@servera ~]$ genisoimage
    genisoimage: Missing pathspec.
    Usage: genisoimage [options] -o file directory ...
    
    Use genisoimage -help
    to get a list of valid options.
    
    Report problems to debburn-devel@lists.alioth.debian.org.
  6. Red Hat Enterprise Linux provides a package that includes a genisoimage command. Use the yum command to locate which RPM provides it and inspect it locally.

    [student@servera ~]$ yum provides '*bin/genisoimage'
    genisoimage-1.1.11-39.el8.x86_64 : Creates an image of an ISO9660 file-system
    Repo        : rhel-8.4-for-x86_64-appstream-rpms
    Matched from:
    Other       : *bin/genisoimage
  7. Use the `--downloadonly option to download the package into your home directory, without installing it. If prompted, use student as the password.

    [student@servera ~]$ sudo yum reinstall genisoimage --downloadonly --destdir /home/student/
    [sudo] password for student: student
    ...output omitted...
    Downloading Packages:
    genisoimage-1.1.11-39.el8.x86_64.rpm                 60 MB/s | 316 kB     00:00
    --------------------------------------------------------------------------------
    Total                                                31 MB/s | 316 kB     00:00
    Complete!
    The downloaded packages were saved in cache until the next successful transaction.
    You can remove cached packages by executing 'yum clean packages'.
  8. Using RPM package management simplifies system administration. The library dependency would have been detected when the software was originally installed. Runtime libraries are identified and stored in the package metadata when a package is built.

    [student@servera ~]$ rpm -q --requires -p genisoimage-*.rpm
    ...output omitted...
    libbz2.so.1()(64bit)
    libc.so.6()(64bit)
    libc.so.6(GLIBC_2.14)(64bit)
    libc.so.6(GLIBC_2.2.5)(64bit)
    libc.so.6(GLIBC_2.3)(64bit)
    libc.so.6(GLIBC_2.3.2)(64bit)
    libc.so.6(GLIBC_2.3.4)(64bit)
    libc.so.6(GLIBC_2.4)(64bit)
    libc.so.6(GLIBC_2.7)(64bit)
    libmagic.so.1()(64bit)
    libpthread.so.0()(64bit)
    libpthread.so.0(GLIBC_2.2.5)(64bit)
    librols.so.0()(64bit)
    libusal = 1.1.11-39.el8
    libusal.so.0()(64bit)
    libz.so.1()(64bit)
    ...output omitted...
  9. Optional: Remove the package that provides the needed libraries.

    1. Remove the libusal package. When prompted, use student as the password.

      [student@servera ~]$ sudo rpm -e $(rpm -qa | grep libusal) --nodeps
      [sudo] password for student: student
    2. Attempt to execute the application. The program fails to run again. If a package provides the application, then use the rpm and yum commands to display the missing library dependencies.

      [student@servera ~]$ genisoimage
      genisoimage: error while loading shared libraries: libusal.so.0: cannot open shared object file: No such file or directory
  10. Return to workstation as the student user.

    [student@servera ~]$ exit
    [student@workstation ~]$

Finish

On the workstation machine, use the lab command to complete this exercise. This is important to ensure that resources from previous exercises do not impact upcoming exercises.

[student@workstation ~]$ lab finish application-dependencies

Revision: rh342-8.4-6dd89bd