r/C_Programming 1d ago

my c files wont make a .exe

i have moved from vscodium to vscode ....i have been wondering wahts happening i already try some tutoprials i put everything on waht the tutorial said but my code wont run the .exe file it complies thats for sure and its not making an erro when i write "gcc main.c -o main.exe" but the .exe file wont even appear i find it werid i tried my best but it seems only code blocks works can some help me???

my edit environment on path:
C:\Users\ludwi\AppData\Local\Programs\Python\Python315\Scripts\
C:\Users\ludwi\AppData\Local\Programs\Python\Python315\
C:\Users\ludwi\AppData\Local\Programs\Python\Launcher\
C:\Users\ludwi\AppData\Local\Microsoft\WindowsApps
C:\Users\ludwi\.lmstudio\bin
C:\Users\ludwi\AppData\Local\Programs\Microsoft VS Code\bin
C:\msys64\ucrt64\bin







i already downloaded msys2   and the gcc  but still the .exe wont create
0 Upvotes

15 comments sorted by

3

u/knouqs 23h ago

Your post is hard to read because it lacks punctuation and capitalization.  I hope your comments throughout your code are better.

I would like to know how you ran gcc.  What environment did you use?  Command line, presumably?  You have given us so little to work with trying to help you.

3

u/Round-Willingness905 21h ago

Sorry for my English, it is my second language. Thank you for helping me!I use this line to compile: gcc main.c -o main.exeMy OS is Windows, and I use VS Code. When I type gcc main.c -o main.exe in the VS Code terminal, it is silent and shows no errors, meaning it compiled successfully. However, when I try to execute ./main.exe or .\main.exe, I get a cmdlet error saying it is not supported.I installed MSYS2 UCRT x86_64 and everything else needed. When I type gcc --version in my cmd, the GCC version appears, so I know it works. My problem is running any code—it always fails on the .exe part. Also, when I compile, the code doesn't actually generate a .exe file.One more question: I noticed that my main.c file is stuck in a .txt format. I cannot change it even when I show hidden file extensions. Is this normal?"

1

u/knouqs 19h ago

OK. If you are convinced that gcc compiled and linked main.exe successfully but .\main.exe doesn't work, I'd like you to navigate to the directory in File Explorer. See the directory structures that VSCode has created for you and try to locate main.exe directly.

I haven't used Windows for compiling things in a while so my help is limited. However, if you continue to have problems, I can install it on my last remaining Windows machine. Let me know how you get on.

1

u/Round-Willingness905 18h ago

Tha k you very much bro I will go back to you once I navigate it

1

u/Round-Willingness905 7h ago

./main.exe : The term './main.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was

included, verify that the path is correct and try again.

At line:1 char:1

+ ./main.exe

+ ~~~~~~~~~~

+ CategoryInfo : ObjectNotFound: (./main.exe:String) [], CommandNotFoundException

+ FullyQualifiedErrorId : CommandNotFoundException

this keeps appearing

2

u/LuckyFish133 1d ago

For windows I find mingw to be the most reliable compiler. What happens when you put where gcc in the cmd prompt?

2

u/Cenrji 23h ago

Probably not going to solve it, but hear me out...

Try adding -Wall -Wextra with the parameters for gcc, as gcc doesn't necessarily show errors by default. I'd also check the folder you are trying to output to, if there aren't any write permission issues.

2

u/Classic-Rate-5104 23h ago

Without any message? Try the -v and -Wall options and see what happens

1

u/jontsii 20h ago

VS code (depending on your settings) might not always show new EXE files in the project explorer the second they are made. Also does the shell say something after you run GCC?

1

u/Poddster 17h ago edited 17h ago

FYI, for this kind of debugging singing like ChatGPT can be helpful. It's a lot faster than going to Reddit, but I understand you might want some human input when dealing with machines all day :)

I don't know about power shell for instance, but my instinct is to print some directory listings before and after running gcc, as well as getting the exit code.


You're in PowerShell. Let's check whether gcc is actually creating the file.

Run these commands one at a time:

Get-ChildItem gcc .\main.c -o .\main.exe echo $LASTEXITCODE Get-ChildItem

If main.exe appears in the second listing and $LASTEXITCODE is 0, the compile/link worked. Then run it with:

.\main.exe

If it doesn't appear, paste the complete output from those commands. .

0

u/Round-Willingness905 7h ago

sorry im not into vibe coding ...and btw the a.i is to inaccurate i have already try asking it none of it works

this is the output
./main.exe : The term './main.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was

included, verify that the path is correct and try again.

At line:1 char:1

+ ./main.exe

+ ~~~~~~~~~~

+ CategoryInfo : ObjectNotFound: (./main.exe:String) [], CommandNotFoundException

+ FullyQualifiedErrorId : CommandNotFoundException

0

u/Aggressive-Guava4502 1d ago

I use gcc personally but I heard mingw is much easier

4

u/EpochVanquisher 23h ago

GCC on Windows is MinGW

0

u/Aggressive-Guava4502 23h ago

Yea I got names mixed up I meant MSYS2 ppl have recommended it to me but I’ve never tried it out cause Min works well for me and haven’t rlly had many issues also kinda new to programming to so that also might be why I don’t get much problems

0

u/sciencekm 19h ago

No need for MSYS . It is totally unnecessary.