error while loading shared libraries: libpython3.8.so.1.0: cannot open shared object file: no such file or directory (ubuntu)

Question:

I am trying to use the GDB debugger using OpenOCD (Ubuntu) for a RISC-V processor running on hardware. I have successfully connected to the RISC-V core with OpenOCD. When I try to run GDB I get the following error message:


riscv32-unknown-elf-gdb: error while loading shared libraries: libpython3.8.so.1.0: cannot open shared object file: No such file or directory***

I don’t know why Python is needed to run this command but I do have Python 3.10 installed on Ubuntu. Do I need Python 3.8 or what is wrong here?

I have checked the GDB toolchain and it is installed correctly.

EDIT

I am not very experienced with software involving compilers etc and Ubuntu so I will try add whatever I think may be useful. Or if anyone can advise any way of checking decencies or have any tests I could do to check, let me know.

Below shows trying to run the RISC-V GDB command on Ubuntu, and showing the error message:

david@DESKTOP-3UBE0P7:/mnt/c/Users/David/.Xilinx/Neorv32_basys3_test_setup_on_chip_debugger/neorv32-main/sw/example/demo_blink_led$ export PATH=$PATH:/opt/riscv/bin
david@DESKTOP-3UBE0P7:/mnt/c/Users/David/.Xilinx/Neorv32_basys3_test_setup_on_chip_debugger/neorv32-main/sw/example/demo_blink_led$ riscv32-unknown-elf-gdb
riscv32-unknown-elf-gdb: error while loading shared libraries: libpython3.8.so.1.0: cannot open shared object file: No such file or directory

IN RESPONSE TO CHARLES DUFFY’S COMMENT

I think I am in the correct place you are talking about but it seems like it is not there.

david@DESKTOP-3UBE0P7:/$ ls
bin   etc   lib    libx32      mnt   riscv-openocd                          run   srv  usr
boot  home  lib32  lost+found  opt   riscv32-unknown-elf.gcc-12.1.0.tar.gz  sbin  sys  var
dev   init  lib64  media       proc  root                                   snap  tmp
david@DESKTOP-3UBE0P7:/$ cd opt
david@DESKTOP-3UBE0P7:/opt$ ls
riscv
david@DESKTOP-3UBE0P7:/opt$ cd riscv/
david@DESKTOP-3UBE0P7:/opt/riscv$ ls
bin  include  lib  libexec  riscv32-unknown-elf  share
david@DESKTOP-3UBE0P7:/opt/riscv$ cd lib
david@DESKTOP-3UBE0P7:/opt/riscv/lib$ ls
bfd-plugins  gcc  libcc1.la  libcc1.so  libcc1.so.0  libcc1.so.0.0.0  libriscv32-unknown-elf-sim.a
Asked By: David777

||

Answers:

According to the error message, GDB is attempting to load a shared library by the name of "libpython3.8.so.1.0," but it is unable to do so. The GDB executable you are using depends on this library, and it appears that the version of GDB you are using was created with Python 3.8 in mind.

Installing Python 3.8, which is the version GDB was created for, is one option for supplying the necessary shared library. You can carry out the subsequent command to do this:

sudo apt-get install python3.8

A symbolic link to a comparable library you have installed on your system could be created as an alternative to trying to find the missing library. The following command, for instance, could be used to create a symbolic link if you have "libpython3.10.so.1.0" installed:

sudo ln -s /usr/lib/x86_64-linux-gnu/libpython3.10.so.1.0 /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0

By making a symbolic link between "libpython3.8.so.1.0" and "libpython3.10.so.1.0," this command should enable GDB to load the necessary library.

You might need to repeat this procedure for any further missing shared libraries, therefore keep in mind that it’s conceivable that other shared libraries are missing as well.

Answered By: Just Adam
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.