Is it possible to debug a mex function in VS Code with MINGW 8.1?
4 views (last 30 days)
Show older comments
I'm trying to debug a mex function in VS Code with MINGW 8.1 and MATLAB R2025a on Windows. I followed the directions in this blog post: https://blogs.mathworks.com/developer/2018/06/19/mex-debugging-vscode. But VS Code refuses to load the symbols and detect the break point. I tried this procedure in several different MATLAB versions, and I believe the difference is related to the `gdb` version that's included with MINGW and how it interacts with VS Code.
- Using MATLAB R2023b, I can successfully debug a mex function using MINGW 6.3, but the procedure no longer works when using MINGW 8.1. Both MINGW 6.3 and 8.1 are supported by this version of MATLAB. https://www.mathworks.com/content/dam/mathworks/mathworks-dot-com/support/sysreq/files/system-requirements-release-2023b-supported-compilers.pdf
- Using MATLAB R2025a, I cannot debug a mex function using MINGW 8.1 through VS Code. The debugging symbols do not appear to load. I tried the troubleshooting steps below.
- I verified that I attached to the right PID by using Process Explorer to verify the mex function was loaded under that PID.
- I double-checked that I called mex with the `-g` option.
- I ran `gdb` from the command prompt, and I was able to attach to the process, set a breakpoint, and stop when calling the mex function. So the symbols are definitely in the dll.
- I tried both my mex function, and the 'explore.c' example included with MATLAB. I get the same results for both cases.
- I tried a stand-alone installation of MINGW 8.1, and a copy of MINGW 8.1 installed as a MATLAB add-on.
- Using MATLAB R2025a, I can compile the mex function using MINGW 8.1, and successfully debug using MINGW 6.3. I can also debug successfully using MINGW 15.1.
While there are other workarounds, I'm hoping for a solution entirely within the MATLAB MINGW addon.
3 Comments
Daewon
on 17 Sep 2025
I have the same problem. I have also tried ming 6.3 and I was not able to get this work for me either.
I have not tried debuging with min 15.1, which I can try next.
Answers (0)
See Also
Categories
Find more on MATLAB Support for MinGW-w64 C/C++ Compiler in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!