c++ - 无法在 C++ 代码块中构建和运行
问题描述
所以我最近刚刚下载了一个名为 Code::Blocks 的 C++ IDE 并创建了一个新项目。但是当我尝试构建并运行它时,代码给出了一些错误。我知道这不是语法或类似问题的问题,因为我运行了 Code::Blocks 提供的默认代码。错误如下:
Project/Target: "firstcpp - Debug":
The compiler's setup (GNU GCC Compiler) is invalid, so Code::Blocks cannot find/run the compiler.
Probably the toolchain path within the compiler options is not setup correctly?!
Do you have a compiler installed?
Goto "Settings->Compiler...->Global compiler settings->GNU GCC Compiler->Toolchain executables" and fix the compiler's setup.
Tried to run compiler executable 'C:\MinGW/bin/gcc.exe', but failed!
Skipping...
Nothing to be done (all items are up-to-date).
在我看来,C++ 编译器存在某种问题,但我认为 Code::Blocks 已经带有 C++ 编译器,所以我不太确定这里有什么问题。我也按照他们的指示去了Settings->Compiler...->Global compiler settings->GNU GCC Compiler->Toolchain executables
,但我不太清楚他们的意思fix the compiler
。这是我所看到的屏幕截图:
如果您需要,这里还有我电脑上的信息:
在这一点上,我不太确定如何解决这个问题。我问过朋友这个问题(他们已经成功下载并使用了Code::Blocks),他们说他们在安装的时候从来没有遇到过这个问题。
解决方案
您需要确保您拥有 GNU Compiler Collection 的有效安装,并且您为工具链选择的路径存在。
如果您尚未安装 GCC,最简单的方法是从下载站点下载与 MinGW 预先捆绑的 Code::Blocks 分发。但是,您也可以通过其他方式安装 GCC,例如:
- 通过 msys2 使用 MinGW 安装 GCC,或
scoop install gcc
在 Windows 上安装 GCC
bin
无论哪种情况,您都需要在 Code::Blocks 中设置工具链时选择包含该目录的安装路径。
推荐阅读
- ios - 在 SwiftUI 中显示具有全屏父视图的工作表
- scala - 从 scala 中的配置文件读取时出现问题
- c# - 在 linq 查询中处理空数组
- formik - Formik - 有没有办法在表单更改时获得新的值对象?
- ios - 打完广告后,声音在游戏中消失
- c# - 单击btnDoAction时如何从gridview获取动态下拉列表控件
- arrays - 如何使用递归检查字符串是否为回文,而无需反转或使用重复数组
- javascript - 在 node.js 上传应用程序中 60 秒后连接重置
- powershell - 如何使用 PowerShell 脚本从通用电子邮件地址发送 Outlook 电子邮件?
- python - 广场在pygame中不断消失