TIL: Fixing ‘file not found’ dependency libraries in Linux

In Ubuntu (Debian/CentOS, and the like) apt is our go to CLI application package installer. It handles everything in a single iconic command that every Linux user knows:

sudo apt install <packageName>

Sometimes, and I still don’t get why or when, a package’s shared library (dependency) is not installed.

For example, this happened today for me with MySQL-Workbench. I run it on the CLI and it shows a dependent library is missing or can’t be found, and up throws an error message like:

$ mysql-workbench
/usr/lib/mysql-workbench/mysql-workbench-bin: error while loading shared libraries: libgdkmm-2.4.so.1: cannot open shared object file: No such file or directory

key points of THE FIX are:

1. Ensure the GNU locate database(s) (e.g. mlocate, slocate), are up to date with current information about file locations.

sudo updatedb

2. Ensure the file exists. (No print out means no file found)

locate libgdkmm-2.4.so.1

3. Reinstall the file if missing.
Here using -f for force install dependencies,, and --reinstall for force reinstall (if already installed).

sudo apt-get install -f --reinstall libgtkmm-2.4-1v5

4. Ensure the application configuration is looking in the correct location for the shared library files.

Today I didn’t need this. But essentially, to run MySQL-Workbench on Ubuntu uses a !#/bin/bash ELF file containing a script of commands to execute prior to starting the application binary. In that script, the following environment variables can be used to define the configuration locations export MWB_BINARIES_DIR=xyz and export LD_LIBRARY_PATH=xyz.

In my case, the application script use those environment variable values on the line that executes the runtime binary, as linker library address(es) to the corresponding shared library files written in C/C++. In interpreted language applications those environment variables values might be used as environment arguments into the executed code (for example in Python) or as library classpath addresses on the runtime execution line (for example in JIT-Java). Alas, I didn’t need to change those locations from default, but that’s how it works.

That’s how to resolve missing shared library dependencies in Ubuntu (and Debian/CentOS, etc).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.