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

1

u/IndoRexian2 May 22 '26

Neither of these worked. I think this is an issue with (my) powershell terminal, it's unable to build at all. II switched to the native msys2 terminal and everything works fine.

1

u/ConstantElegant5781 May 22 '26

Have you tried the terminal provided with a default install of cygwin? Beyond the cygwin default packages, I usually also install the following cygwin packages:

gcc-core, gcc-g++, vim, make, procps-ng

The setup program for the 64-bit version of cygwin is currently available at:

https://www.cygwin.com/setup-x86_64.exe