C语言 代码::块无法编译应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30558261/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Code::Blocks Can't compile application
提问by SammyMe
This is my hello world code:
这是我的 hello world 代码:
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Hello world!\n");
return 0;
}
When I'm trying to run application I'm getting an error:
当我尝试运行应用程序时,出现错误:
Target uses an invalid compiler; run aborted
So I went to Settings->Compiler->Toolchain Executables, and I selected C:\MinGW\bin, I have also tried C:\MinGWand I still get the same error.
所以我去了设置->编译器->工具链可执行文件,我选择了C:\MinGW\bin,我也试过了 C:\MinGW,我仍然得到同样的错误。
I have installed Code::Blocks with mingw from the official Code::Blocks site.
我已经从官方 Code::Blocks 站点安装了带有 mingw 的 Code::Blocks。
Please help, I want start learning C but I can't...
请帮忙,我想开始学习C,但我不能......
回答by
You either have the wrong compiler selected in your project's build options ORyou don't have executables set in your compiler settings.
你要么有错误的编译器项目的构建选项中选择或者你没有在你的编译器设置中设置的可执行文件。
To select your compiler in your project:
要在项目中选择编译器:
First, go to the Projectmenu and select Build options:
首先,转到Project菜单并选择Build options:


Then, in the Build optionsdialog, select the compiler you have set up as described in your question:
然后,在Build options对话框中,选择您按照问题中所述设置的编译器:


To change your compiler's executables:
要更改编译器的可执行文件:
Go to Settingsand then Compiler:
转到Settings然后Compiler:


Then select Toolchain Executables:
然后选择Toolchain Executables:


and fill in your executable names:
并填写您的可执行文件名称:


回答by greg leblanc
I'm using windows 10 and was having the same problem. I used the Setting>Compiler> Toolchain executables. Auto-detect button. It's at the end of the Compiler's installation directory: path box. After clicking the button it was set to C:\Program files(x86)\codeblocks\mingw
我正在使用 Windows 10 并且遇到了同样的问题。我使用了设置>编译器>工具链可执行文件。自动检测按钮。它在编译器安装目录的末尾:路径框。单击按钮后,它被设置为 C:\Program files(x86)\codeblocks\mingw
回答by Mancy Saxena
I had the same error, figured it was Environment error, download the mingw-setup.exe file from CodeBlocks ide. After installation Go to Settings>>Compiler>>Reset Defaults
我有同样的错误,认为是环境错误,从 CodeBlocks ide 下载 mingw-setup.exe 文件。安装后转到设置>>编译器>>重置默认值

