[英]Error When Compiling a Simple C Program File in Windows 10 CMD Prompt Using MinGW (gcc: error: No such file or directory)
As the title of the post says, I'm getting an error when trying to compile a simple Hello World C program.正如帖子的标题所说,我在尝试编译一个简单的 Hello World C 程序时遇到错误。 I am on Windows 10, and I believe I have properly installed MinGW onto my PC (and I made sure to add all the extra gcc compilers in the MinGW Installation Manager).我在 Windows 10 上,我相信我已经在我的 PC 上正确安装了 MinGW(并且我确保在 MinGW 安装管理器中添加所有额外的 gcc 编译器)。
Some basic info: I am on Windows 10, I am using MinGW64, I am in the correct directory as my Hello.c file, I am using the correct case (literally copied and pasted), I have tried using the full file location on both the C file and executable (although that shouldn't matter as far as I know), I have changed the PATH of my environmental variables (both user and system) to include C:\MinGW\bin
(wouldn't even get this far without this), and I made sure that the file is a C Source Code file from its properties (wrote it from the Visual Studios Text Editor).一些基本信息:我在 Windows 10 上,我正在使用 MinGW64,我在正确的目录中作为我的 Hello.c 文件,我使用正确的大小写(字面上复制和粘贴),我尝试使用完整的文件位置C 文件和可执行文件(尽管据我所知这并不重要),我已经更改了我的环境变量(用户和系统)的 PATH 以包括C:\MinGW\bin
(甚至不会得到这个远没有这个),并且我确保该文件是来自其属性的 C 源代码文件(从 Visual Studios 文本编辑器编写)。
I for the life of me cannot figure what I'm doing wrong.我一生都无法弄清楚我做错了什么。 It says it can't find the file when it's right there它说它在那里时找不到文件
I even tried adding in C:\MinGW\libexec\gcc\mingw32\9.2.0
(got the 9.2.0 from gcc -v
) in the PATH info, but that did nothing.我什至尝试在 PATH 信息中添加C:\MinGW\libexec\gcc\mingw32\9.2.0
(从gcc -v
获得 9.2.0 ),但这没有任何作用。
Appreciate any and all suggestions!感谢任何和所有建议!
You should not be working under a system folder C:\Windows\System32
.您不应该在系统文件夹C:\Windows\System32
下工作。 Probably there are access restrictions (eg from antivirus) that cause you to run into problems.可能存在导致您遇到问题的访问限制(例如来自防病毒软件)。
I also recommend you don't do it in a path containing spaces or special characters.我还建议您不要在包含空格或特殊字符的路径中执行此操作。
Try under a folder C:\Temp
for example.例如,在文件夹C:\Temp
下尝试。
If you want to try with a more recent MinGW-w64 you can get it from https://winlibs.com/ .如果您想尝试使用更新的 MinGW-w64,您可以从https://winlibs.com/获得它。 That site also gives an example on how to use it from the Command Prompt.该站点还提供了有关如何从命令提示符中使用它的示例。
If you're new to all this you may also want to consider an IDE like Code::Blocks or Visual Studio Code.如果您不熟悉这一切,您可能还需要考虑 IDE,例如 Code::Blocks 或 Visual Studio Code。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.