首页 > 解决方案 > 由于路径问题,代码::块不能与 MSYS2 MinGW 一起使用

问题描述

我使用下载的二进制codeblocks-20.03-setup.exe在 Windows 10 PC 上安装了 Code::Blocks 。我调整了设置以指向我的 Msys2 MinGW 编译器C:\msys64\mingw64和调试器C:\msys64\usr\bin\gdb.exe。然后,我使用 Code::Blocks 在 c 中创建了一个带有默认控制台应用程序的项目。它可以使用 Code::Blocks 编译和运行。

当我调试它时它失败了。Code::Blocks 给出错误:

Cannot open file: /c/GitLab/debugging-c-code/Exercise Files/Ch02/02_01/02_02_ide/main.c
At /c/GitLab/debugging-c-code/Exercise Files/Ch02/02_01/02_02_ide/main.c:6

main.c 文件在 Code::Blocks 中打开。我认为/c/vsc:\部分是问题所在。我不知道如何解决 Code::Blocks 的问题。

我的设置:

[..]which gcc
gcc is an external : C:\msys64\usr\bin\gcc.exe

[...]gcc --version
gcc (GCC) 9.1.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[...]which gdb
gdb is an external : C:\msys64\usr\bin\gdb.exe

[...]gdb --version
GNU gdb (GDB) 8.2.1
Copyright (C) 2018 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.

标签: cmingwcodeblocksmsys2

解决方案


我解决了这个问题......在阅读了来自 HolyBlackCat 的评论后。Cygwin 将破坏路径,因为它假定它位于 Cygwin 环境中。

更新了我的 MSYS 安装并将 GDB 安装为完整工具链的一部分:

pacman -S mingw-w64-x86_64-toolchain

现在 GDB、GCC 和 Codeblocks 彼此满意,并以每个人都能理解的方式共享调试信息。现在 GDB 和 GCC 都驻留在C:\msys64\mingw64.

我最初只安装了 GCC,然后根据需要安装了其他部分。


推荐阅读