STM32 Cube IDE 1.17.0 on Linux Mint 22.1 MATE: Resolving GDB Version Error When Programming External Board via ST-LINK

Created on: 2025-02-04

If you're using STM32 Cube IDE 1.17.0 on Linux Mint 22.1 MATE and encountering issues programming an external board using the ST-LINK debugger, you may have seen an error like the following:

Could not determine GDB version using command: arm-none-eabi-gdb --version
arm-none-eabi-gdb: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory

This error arises because STM32 Cube IDE, which integrates tools like arm-none-eabi-gdb, requires specific versions of the libraries, particularly libncurses.so.5 and libtinfo.so.5, which are often unavailable in newer versions of Linux Mint. Here's a step-by-step guide to resolve this issue and get STM32 Cube IDE running smoothly on your system.

STM32CubeIDE version 1.17.0 for STM32 embedded software development
STM32CubeIDE version 1.17.0 for STM32 embedded software development

The Problem: Missing Dependencies for STM32 Cube IDE 1.17.0

When you try to program an external board with the ST-LINK debugger in STM32 Cube IDE, it attempts to run arm-none-eabi-gdb to communicate with the hardware. However, the IDE fails to recognize the required GDB version, throwing the following errors:

arm-none-eabi-gdb: error while loading shared libraries: libncurses.so.5: version `NCURSES_5.3.20021019' not found (required by arm-none-eabi-gdb)
arm-none-eabi-gdb: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory

This is caused by missing or incompatible versions of libncurses and libtinfo. Specifically, STM32 Cube IDE expects libncurses.so.5, but Linux Mint 22.1 (based on Ubuntu 22.04) ships with libncurses.so.6. Additionally, the required libtinfo.so.5 is also not found in the default repositories.

Why You Can't Use Symlinks Alone:

Many users attempt to create symlinks between the libraries:

sudo ln -s /usr/lib/x86_64-linux-gnu/libncurses.so.6 /usr/lib/x86_64-linux-gnu/libncurses.so.5

However, this approach does not resolve the issue because arm-none-eabi-gdb specifically looks for version 5 of `libncurses`, which may have different internal symbols compared to version 6. The mismatch in versions causes the tool to fail, as you might see when the version errors pop up for NCURSES_* symbols.

The Solution: Add a Legacy Repository, Install libncurses5, and Remove the Repository

The correct solution involves adding a legacy Ubuntu 20.04 repository, installing libncurses5 from it, and then removing the repository after installation. This avoids potential issues with future updates and ensures you get the correct version of the necessary libraries.

Step-by-Step Solution:

1. Add the Legacy Ubuntu 20.04 Repository

To get libncurses5, add the Ubuntu 20.04 (Focal Fossa) repository:

sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu/ focal main universe"
sudo apt update

2. Install the Required Libraries

Install libncurses5 (and its dependencies, like libtinfo5) from the newly added repository:

sudo apt install libncurses5 libtinfo5

Optionally, if you need 32-bit libraries for compatibility with STM32 Cube IDE, use:

sudo apt install libncurses5:i386 libtinfo5:i386

The above may not be necessary.

3. Verify the Installation

Confirm that libncurses5 is installed:

dpkg -l | grep libncurses5

4. Remove the Legacy Repository

After successfully installing libncurses5, remove the legacy repository to avoid potential conflicts with future updates. This ensures that your system continues to update from the correct Mint repositories:

sudo add-apt-repository --remove "deb http://archive.ubuntu.com/ubuntu/ focal main universe"
sudo apt update

5. Check if Everything Works

Now that the repository has been removed, you can verify that STM32 Cube IDE works as expected. Restart the IDE and attempt to program your board again via the ST-LINK. The error related to arm-none-eabi-gdb should now be resolved.

Why Remove the Legacy Repository?

While adding the legacy repository temporarily solves the issue of missing dependencies, it's important to remove the repository after installation for several reasons:

  • Avoid Conflicts with Newer Packages: Legacy repositories may contain older versions of packages that could interfere with the current, supported versions in Linux Mint's official repositories.
  • Security Risks: Installing packages from outdated repositories may expose your system to known vulnerabilities that have been fixed in newer versions.
  • Prevent Future Dependency Issues: If the legacy repository remains enabled, apt may pull older packages when performing updates or installing new software, which could cause unexpected behavior or stability problems.

By removing the repository after installing the necessary packages, you ensure your system remains up-to-date with the latest stable software while still resolving the dependency issue specific to STM32 Cube IDE.

Conclusion

To resolve the GDB version error when programming an external board with STM32 Cube IDE 1.17.0 using ST-LINK on Linux Mint 22.1 MATE, follow the steps outlined above. Adding a legacy repository temporarily allows you to install libncurses5, but it’s crucial to remove the repository afterward to avoid any future conflicts or security risks. By doing this, you ensure that your development environment remains stable and up-to-date.