Home / Alt manpages / gi-inspect-typelib(1)

  • gi-inspect-typelib(1)
  • User command
  • linux

Inspect GObject Typelibs and Their Runtime Libraries

A program loads a GObject namespace fine, then blows up resolving native symbols: gi-inspect-typelib names the libraries and typelibs it depends on. It answers two practical questions: which shared libraries implement a namespace, and which other typelibs it needs. The examples use the installed GObject Introspection tooling from GLib package version 2.80.0-6ubuntu3.9. Allow about ten minutes, including time to identify the namespace and version you need.

This is a read-only inspection workflow. It does not install packages, alter a typelib, reload a service or require sudo. You need a Linux shell and the libglib2.0-dev-bin package, or an equivalent package that provides the command.

1. Check the installed command

Start by confirming which executable your shell will run and which package supplied it:

$ command -v gi-inspect-typelib
/home/linuxbrew/.linuxbrew/bin/gi-inspect-typelib
$ dpkg-query -W -f='${Package} ${Version}\n' libglib2.0-dev-bin libglib2.0-dev:amd64
libglib2.0-dev-bin 2.80.0-6ubuntu3.9
libglib2.0-dev 2.80.0-6ubuntu3.9

The Debian package also provides an architecture-prefixed name, such as x86_64-linux-gnu-gi-inspect-typelib. Use that form when you are inspecting files for a cross-compilation target and its search paths. For ordinary native inspection, the unprefixed command is the clearest choice.

Checkpoint: the command must resolve to the installation whose typelibs you intend to inspect. A different executable earlier in PATH can produce different results.

2. Choose a namespace and pin its typelib version

The command takes a namespace, not a filename. For example, Gio refers to a typelib such as Gio-2.0.typelib, so the corresponding version argument is 2.0. Pin the version when a machine can contain more than one installed version:

$ gi-inspect-typelib --typelib-version 2.0 --print-shlibs Gio
shlib: libgio-2.0.so.0

The two inspection modes are mutually descriptive rather than interchangeable. --print-shlibs prints the shared libraries that implement the namespace. --print-typelibs prints the other typelibs it depends on. The command does not print every symbol, function or object in the namespace.

If you omit --typelib-version, the installed tool chooses the newest available version when several versions exist. That is convenient for an interactive check but a poor assumption for a build log or diagnostic report. Record the explicit version whenever the result must be repeatable.

3. Find the libraries behind a namespace

Ask for shared libraries when a program loads introspection data but fails later while resolving native symbols. The output is intentionally compact:

$ gi-inspect-typelib --typelib-version 2.0 --print-shlibs Gio
shlib: libgio-2.0.so.0

The shlib: value is a library name, not proof that the file is present in every library search path. If you need to check the dynamic linker separately, use a read-only lookup such as:

$ ldconfig -p | grep -F 'libgio-2.0.so.0'
        libgio-2.0.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libgio-2.0.so.0

Your architecture and linker cache may show a different path. An empty lookup means the library is not in that cache; it does not by itself prove that no private or container-local copy exists.

4. List typelib dependencies

Use the second mode to see the other introspection files required by Gio:

$ gi-inspect-typelib --typelib-version 2.0 --print-typelibs Gio
typelib: GObject-2.0
typelib: GLib-2.0
typelib: GModule-2.0

These names describe typelib dependencies, not shared-library filenames. For example, GLib-2.0 is not a command to run and should not be passed to ldd. Use the --print-shlibs mode against a namespace when you need the native library mapping.

To inspect another namespace, replace only the final argument and use the version documented by its filename. This example checks GLib and leaves the version selection to the installed command:

$ gi-inspect-typelib --print-shlibs GLib
shlib: libgobject-2.0.so.0
shlib: libglib-2.0.so.0

Do not assume that every namespace maps to exactly one library. The output can contain more than one shlib: line.

5. Diagnose a missing or mismatched typelib

A namespace and version must resolve to an installed typelib in the command's search paths. If the version is absent, the command fails before printing a library list:

$ gi-inspect-typelib --typelib-version 999.0 --print-shlibs Gio
Failed to load typelib: Typelib file for namespace 'Gio', version '999.0' not found
$ printf 'exit status: %s\n' "$?"
exit status: 1

The exact diagnostic can vary slightly between releases, but the useful clues are the namespace and requested version. Check the filename under the relevant typelib directories, then rerun with the version embedded in that filename. Do not "fix" the error by choosing the newest version if the application specifically requires another one.

A failure can also mean that you are invoking the wrong architecture-prefixed executable. Native and cross-compilation searches are deliberately different. Confirm command -v, the package architecture, and the namespace version before changing environment variables or build files.

6. Keep the result useful in scripts

Both modes print one labelled result per line and write diagnostics to standard error when loading fails. That makes a small shell check practical, but do not parse the human wording of an error as an API. Check the exit status and keep the namespace and version in your log:

$ namespace='Gio'
$ version='2.0'
$ if gi-inspect-typelib --typelib-version "$version" --print-shlibs "$namespace"; then
>     echo "typelib check passed: $namespace-$version"
> else
>     echo "typelib check failed: $namespace-$version" >&2
>     exit 1
> fi
shlib: libgio-2.0.so.0
typelib check passed: Gio-2.0

Keep namespace and version as separate, quoted shell variables. They should come from trusted configuration, not from an unreviewed string that can add shell syntax or alter the command line.

Done means

  • You confirmed which gi-inspect-typelib executable and package version are in use.
  • You used --print-shlibs for native library names and --print-typelibs for introspection dependencies.
  • You pinned --typelib-version when the result needs to be reproducible.
  • You checked the exit status and treated missing namespaces or versions as search-path or package problems.
  • You left installed typelibs, libraries and services unchanged.