DarkenRaul1
DarkenRaul1

Reputation: 3

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. 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).

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).

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

(here's a screenshot of what I'm dealing with)

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.

Appreciate any and all suggestions!

Edit: Brecht's suggestion was correct. My issue was putting the files and attempting to do all this in the Windows\System32 directory. Once I put it in C:\temp it finally worked.

Upvotes: 0

Views: 530

Answers (1)

Brecht Sanders
Brecht Sanders

Reputation: 7287

You should not be working under a system folder C:\Windows\System32. Probably there are access restrictions (e.g. 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.

If you want to try with a more recent MinGW-w64 you can get it from 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.

Upvotes: 2

Related Questions