r/C_Programming • • May 21 '26

Question gcc unable to create the executable

Hi y'all, I've been trying to learn C and I installed mingw using msys2.

I'm trying to compile the following code:

// hello.c
#include <stdio.h>

int main(void)
{
    printf("Hello, Windows!\n");
    return 0;
}

When running gcc hello.c -o hello.exe, I don't get any executable. I've tried reinstalling mingw, and I've also checked that I'm running the command on the same directory where the file. I also added the particular folder to Windows Defender Exclusion list but still can't get anything done. What am I doing wrong?

Edit: Got it to work by changing my terminal from Powershell to Git Bash.

Edit 2: Even msys2 terminal works. I'm using that only from now-onwards.

13 Upvotes

18 comments sorted by

View all comments

Show parent comment

4

u/This_Growth2898 May 21 '26

powershell, command line (cmd.exe) and bash have different syntax. There are also other shells.

My advice is to choose one of them according to your textbook/tutorial/mentor and stick to it. Generally, if you use gcc, you would like to use bash with it. They are from the same toolset (GNU), and a random piece of advice on the Internet would probably assume you use them together.