MATLAB: Matlab -Dgdb doesn’t work on Ubuntu

debuggingMATLABmex

When trying to debug a mex file on Ubuntu 18.04 with Matlab 2018b, when I run
matlab -Dgdb
in the terminal, I get the following error:
gdb: symbol lookup error: /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0: undefined symbol: XML_SetHashSalt
I've tried to reinstall libpython3.6m.so but the problem persists. The version of gdb is 8.1.0 and works fine when launched as standalone.
How can I fix it ?

Best Answer

I don't know if this is a perfect solution but doing this in the current environment before `matlab -Dgdb` resolves it for me.
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libexpat.so
Related Question