Problem with esp32 debug for Ubuntu. (undefined symbol: _Py_ZeroStruct)

Indeed Ubuntu 20 support seems to lacking / hacky right now. I installed a fresh Ubuntu 20.04 LTS in a VM. Even got an install error in VSCode which was solvable though. The problem with the xtensa-esp32-elf-gdb is however reproducable:

max@max-VirtualBox:~/.platformio/packages/toolchain-xtensa32/bin$ ldd xtensa-esp32-elf-gdb 
	linux-vdso.so.1 (0x00007ffdc2af0000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fed2a94f000)
	libncurses.so.5 => not found
	libtinfo.so.5 => not found
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fed2a800000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fed2a7dd000)
	libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007fed2a7d8000)
	libpython2.7.so.1.0 => not found
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fed2a5e4000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fed2a968000)

So it’s missing libncurses.so.5, libtinfo.so.5 and libpython2.7.so.1.0.

With the default ncurses state

$ ls -la /usr/lib/x86_64-linux-gnu/libncurses*
lrwxrwxrwx 1 root root     17 Mai 22 00:02 /usr/lib/x86_64-linux-gnu/libncurses.so.6 -> libncurses.so.6.2
-rw-r--r-- 1 root root 162024 Feb 26 08:14 /usr/lib/x86_64-linux-gnu/libncurses.so.6.2
lrwxrwxrwx 1 root root     18 Mai 22 00:02 /usr/lib/x86_64-linux-gnu/libncursesw.so.6 -> libncursesw.so.6.2
-rw-r--r-- 1 root root 231504 Feb 26 08:14 /usr/lib/x86_64-linux-gnu/libncursesw.so.6.2

I did the following:

sudo apt install libncurses5 libtinfo5 libncursesw5 python2.7 libpython2.7

Which fixes all library errors in ldd for me:

max@max-VirtualBox:~/.platformio/packages/toolchain-xtensa32/bin$ ldd xtensa-esp32-elf-gdb 
	linux-vdso.so.1 (0x00007ffc35fb0000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f7d04d52000)
	libncurses.so.5 => /lib/x86_64-linux-gnu/libncurses.so.5 (0x00007f7d04d2c000)
	libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007f7d04cfe000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f7d04baf000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f7d04b8c000)
	libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f7d04b87000)
	libpython2.7.so.1.0 => /lib/x86_64-linux-gnu/libpython2.7.so.1.0 (0x00007f7d04819000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f7d04627000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f7d04d6b000)
	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f7d0460b000)

And GDB starts up:

max@max-VirtualBox:~/.platformio/packages/toolchain-xtensa32/bin$ ./xtensa-esp32-elf-gdb 
GNU gdb (crosstool-NG crosstool-ng-1.22.0-80-g6c4433a) 7.10
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-build_pc-linux-gnu --target=xtensa-esp32-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) 

Now the question is: Why in the world doesn’t this work for you when you do the same thing?

Can you:

  • remove all previous symlink hacks regarding ncurses5
  • the output of ldd ~/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-gdb
  • the output of sudo apt install libncurses5 libtinfo5 libncursesw5 python2.7 libpython2.7
  • again the output of the ldd command
1 Like