0

I installed gnu GCC and GDB with MSYS2.
This is the command I used:

pacman -Syu
pacman -S --needed base-devel mingw-w64-x86_64-toolchain

I added environment variable "C:\msys64\mingw64\bin" and I changed the compiler location in Code::Blocks.

It works well in "compile & run", but when I'm debugging, at the last line of the main function, it shows this error:

C:\M\B\mingw-w64\crt\crt.exe.c not found

I tried other MinGW versions, such as 8.1.0, and it worked out well. I also tried Cygwin, but it started debugging and finished.

2
  • I use MSys2 and I have used Code::Blocks -- but no long do. While CB is a good tool, it is quite dated. MSys2 provides very good terminals in which you can run gdb manually for small projects. For larger projects, I've become a fan of VSCode (or vscodium) as an IDE. Yes, like all IDEs it has a learning curve, but the MS documentation is quite good -- even for Linux use. Your install looks fine, the -toolchain package is just a meta-package that installs a number of gcc utilities (including gdb), the C:\M\B\mingw-w64 error doesn't match your "C:\msys64\mingw64\bin" path - double-check Commented Aug 29, 2024 at 2:43
  • That's normal behavior. You're trying to debug beyond main(), so it tries to open crtexe.c which is where main was called from. Why is that a problem? Commented Aug 29, 2024 at 10:29

1 Answer 1

1

Open Code::Blocks

Configure debugger

  • In the top menu go to Settings and select Debugger...
  • In the left pane select GDB/CDB debugger
  • Select the desired config on the left
  • Set the location of bin\gdb.exe

Configure compiler to use the debugger

  • In the top menu go to Settings and select Compiler...
  • Under Selected compiler choose GNU GCC Compiler
  • Click the tab Toolchain executables
  • Set Debugger to the config you configured above
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for your answer,but I did tried both of it.
Full instruction is at winlibs.com/#usage-codeblocks if you are willing to try the winlibs standalone build instead of MSYS2.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.