MinGW-w64 GDB not working
Answered
Following the instructions in [Configuring CLion on Windows](https://www.jetbrains.com/help/clion/quick-tutorial-on-configuring-clion-on-windows.html#MinGW) with MinGW-w64, I installed MinGW-w64 version 8.1.0 from the installer. When trying to debug a program, though, GDB crashes whenever a function is called (e.g. `p f(1, 2)`). According to [this](https://stackoverflow.com/questions/59677810/when-calling-a-function-in-debug-mode-gdb-is-crashed) it's a bug in GDB 8.1. But I can't upgrade the MinGW version to any newer version since the one I installed is the newest available on the installer. How can I fix this?
Please sign in to leave a comment.
Hello!
You can try installing MSYS2 (https://www.msys2.org/), maybe it contains a more recent GDB version.
I did try that, and MSYS2 does have a newer GDB (and MinGW-w64) version, but CLion doesn't seem to detect it when I point it to the MSYS2 root folder. And the msys64/mingw64 folder seems to be empty (it contains empty bin/, lib/, share/, etc/ folders), so when I point CLion to that, it also gives an error when configuring the Toolchain.
Have you installed the required packages in MSYS2? You can install "
mingw-w64-x86_64-toolchain
", for example - https://packages.msys2.org/group/mingw-w64-x86_64-toolchain.Yes, but all the binaries get installed in msys64/usr/bin, not msys64/mingw64/bin, and CLion apparently doesn't work with MSYS2.
I've done the following: installed MSYS2 using msys2-x86_64-20200903.exe, ran MSYS2, executed pacman -Syu, closed and reopened MSYS2, executed pacman -S mingw-w64-x86_64-toolchain (selected the default "all" option) and as a result compilers and gdb were installed in C:\msys64\mingw64\bin.
Thanks for your help, Anna! Apparently I was running the wrong `pacman` command. The problem now seems to be that CMake detects a "broken" gcc compiler:
I followed your instructions exactly. Here is a screenshot of the Toolchains menu:
It was ok on my side. I would advise you to delete the entire MSYS folder and perform the exact same steps as in my previous comment.
I did that and got the same outcome. But I saw that this seems to be a problem with the latest MSYS2 version (see here), so I downgraded to msys2-x86_64-20200720.exe, and it all seems to work now. Thanks for your assistance!