簡體   English   中英

由於路徑問題,代碼::塊無法與 MSYS2 MinGW 一起使用

[英]Code::Blocks not working with MSYS2 MinGW due to path problems

我使用下載的二進制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 編譯和運行。

當我調試它時,它失敗了。 代碼::塊給出一個錯誤:

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/ vs c:\\部分是問題所在。 我不知道如何解決 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,然后根據需要安裝了其他部分。

確保 CodeBlocks、MinGW-w64 或源項目所在的路徑中沒有任何特殊字符(空格、非 ASCII 字符)。

有關如何使用 MinGW-w64 配置 CodeBlocks 的更多信息,請訪問: https ://winlibs.com/#usage-codeblocks

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM