Author Topic: Compiling in the Windows Command Prompt  (Read 7485 times)

Offline 93NickCousar

  • Single posting newcomer
  • *
  • Posts: 6
Compiling in the Windows Command Prompt
« on: September 10, 2018, 10:20:51 pm »
So this question might not be entirely relevant to Code::Blocks, but it has been asked before in a previous thread: http://forums.codeblocks.org/index.php/topic,9314.msg66340.html#msg66340, so I'm assuming it is allowed. Anyways, I downloaded the codeblocks-17.12mingw-setup.exe version and everything works fine. I've been learning how to write programs as console applications. But I want to be able to use a console that doesn't close every time it finishes executing a program. So how do you compile and run a source file in a Windows command prompt? Whenever I try the command

>gcc main.c

I get this error: "gcc is not recognized as an internal or external command"
And same goes for >minGW main.c

The linked thread had this to say, but I'm not sure what they meant by PATH variable:

Hi !

Either it is not installed, either it is not in the PATH environment variable.

Did you install the bundle that includes GCC ?

Dje



Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Compiling in the Windows Command Prompt
« Reply #1 on: September 11, 2018, 03:39:30 pm »
This https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/set_1 and in particular you need to add the path to the executable to the list of paths. Search how the PATH variable is managed on windows. https://en.wikipedia.org/wiki/PATH_(variable)

And please learn how to use the search engine of your choice. It saves time.  8)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]