c - 由于路径问题,代码::块不能与 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.
解决方案
我解决了这个问题......在阅读了来自 HolyBlackCat 的评论后。Cygwin 将破坏路径,因为它假定它位于 Cygwin 环境中。
更新了我的 MSYS 安装并将 GDB 安装为完整工具链的一部分:
pacman -S mingw-w64-x86_64-toolchain
现在 GDB、GCC 和 Codeblocks 彼此满意,并以每个人都能理解的方式共享调试信息。现在 GDB 和 GCC 都驻留在C:\msys64\mingw64
.
我最初只安装了 GCC,然后根据需要安装了其他部分。
推荐阅读
- python - 查找 pandas 数据框列的 n 个最大值(当为字符串时)
- android - Flutter 内存泄漏
- swiftui - SwiftUI 如何在新视图中链接 ForEach 索引和照片索引?
- arrays - 在C中将结构复制到结构数组的正确方法
- terminal - 将日志放在无限循环生成的标准输出上的最佳方法是什么?
- asp.net-core - 发布后重置 NLog 配置文件
- java - 整数迭代器未显示最后一个整数
- c# - 如何在文本框MVP c#中显示选定的行
- json - 如何在反应打字稿中从json文件中获取和显示数据
- arrays - 检查一些变量后向结构数组添加新结构