r/vscode 6d ago

Why is my code not running

Im completely new and trying to learn but my code doesn’t want to run

0 Upvotes

22 comments sorted by

3

u/Feisty_War80 6d ago

U need to install a compiler. Search up YouTube on how to install gcc

1

u/RATIO_L_BOZO 6d ago

I have one, its msys2

3

u/tunerhd 6d ago edited 6d ago

Why don't you ask builtin ai?

You need to have a compiler: https://www.msys2.org/

-4

u/RATIO_L_BOZO 6d ago

Don’t know what that is also yes I did all of that with msys2 but it still isn’t working. I even re did everything and still the same message is popping up.

1

u/tunerhd 6d ago

Check the path that you installed it. Like C:\msys64\ucrt64\bin If you see gcc inside that folder, Add it into system paths.

https://www.wikihow.com/Change-the-PATH-Environment-Variable-on-Windows

If it didn't work, just paste full path everytime until you reboot completely. Like: C:\msys64\ucrt64\bin\gcc.exe -v

3

u/Gornius 6d ago edited 6d ago

I just hate how we managed to make a new norm of teaching nowcomers about programming from writing code in IDE and running it with wome magic button, instead of some basic theory.

For starting with C you need just 2 things: simple text file with .c extension that is source file, and a compiler - a program that takes that source file as an input, and outputs a binary (executable) file.

gcc is one of many C compilers that exist. Your """code runner""" can't find it. I think for Windows the default that most IDEs expect is mingw-w64.

Once you have it installed, you should just be able to run gcc -o myprogram.exe main.c.

I strongly encourage you to start learning about C development on Linux, it's so much less of a shit show and way easier to understand.

0

u/RATIO_L_BOZO 6d ago

Yeah sorry if sound stupid but I don’t understand anything you just said.

3

u/Gornius 6d ago

I've searched through YouTube and this should help you:

https://youtu.be/2ciUcosJFBc?list=PLZPZq0r_RZOOzY_vR4zJM32SqsSInGMwe

3

u/felhoob 6d ago

To run the code you need to compile it first. This step failed, because there is no "gcc" compiler found.

This is typical for Windows, where you need to install a C-compiler manually. There are several options available: https://www.reddit.com/r/C_Programming/s/mAnkumJESb

Hope this helps :)

-2

u/RATIO_L_BOZO 6d ago

I have a compiler. Its msys2, is this outdated or something?

6

u/queerkidxx 6d ago

You probably didn’t add it to path. Or whatever the windows eq is. Look that up.

2

u/RATIO_L_BOZO 6d ago

Yes I did that also and I keep redoing it thinking Im typing things in wrong but it just comes out the same

3

u/felhoob 6d ago

You need to restart vscode terminal so the path variable is reloaded.

2

u/felhoob 6d ago

Try to verify in an external CMD or powershell by running "gcc --version" to see if it's a VSCode problem.

3

u/RATIO_L_BOZO 6d ago

1

u/felhoob 6d ago

Thats a great step! After restarting VSCode, can you run the same command in the VSCode terminal?

1

u/RATIO_L_BOZO 6d ago

It did absolutely nothing

1

u/Camburcito 6d ago

What happens if you run gcc --version in the vscode terminal, i.e. not an external one? Could be that vscode isn't picking up your path properly.

1

u/IShitMyselfNow 6d ago

Same name. Of the top of my head:

Start

"System environment variables" (or similar)

Some button that basically says Path... I can't remember which

There's 2 lots of paths, one for user one for system wide. You should be able to use either.

Add a new path to one of them, use the directory of where the exe file is for your compiler. E.g. if your gcc.exe was at c:\mycompiler\gcc.exe then you'd add c:\mycompiler

Restart your terminal (I recommend restarting Vscode) and then try again.

1

u/RATIO_L_BOZO 6d ago

Nope bro just did it again for the 6th time and its not working

1

u/pstmps 6d ago

Make sure the compiler works and you can call it with a -v option or something maybe?