+9

How do I install GCC compiler on Windows 10 (64 bit)?

I need to install gcc compiler from https://gcc.gnu.org/ to run C programs using command prompt. How do I do it?

8/21/2018 1:01:34 PM

Infinity

25 Answers

New Answer

+7

Installing with MinGW is probably the easiest option. In the MinGW installation manager, under "basic setup", you'll want to check "mingw-gcc-g++", then hit Installation -> apply changes. You should then see the gcc binaries in C:/MinGW/bin. To be able to run gcc from the command line from anywhere, you will need to add C:/MinGW/bin to your PATH. To do that: - Windows+X -> System - Search for "Environment variables" - "Edit System Environment Variables" - "Advanced" Tab - "Environment Variables..." - Find Path in the System variable list and hit Edit - Add C:/MinGW/bin, if it isn't already Then you can open a terminal window in the folder where your code is and write gcc -o output.exe source.c And compile it.

+7

I struggled with this when i first got introduced to c, because everyone acted like it was common sense. I can give you a basic run down, but not a full walk through. you need to download some version of gcc like from the link you shared if it is safe. Once you have it downloaded and installed you’re gonna need a text editor of some sort. I personally use notepad++, but every programmer swears that some text editors are better than others. Once you have a text editor downloaded when you make a new text in the editor you should save the project somewhere, but when you open up the save as section there will be .C files and probably some others you can save it as, so you would save it as a .C If you look up Derek Banas on youtube he does some great tutorials in c and how to install everything.

+4

Infinity I'm not too sure about this, but from GCC page we have 3 choices for installing under Windows, Cygwin, MinGW and mingw-w64. The MinGW Downloads link lead to this site, there is an exe file mingw-get-setup.exe. The description says: Description mingw-get is a tool to assist users in the management of MinGW and MSYS software installations. https://sourceforge.net/projects/mingw/files/Installer/

+4

Ipang Richard Johnson thanks!

+4

The "How to install compiler X" routine is burned into my brain from doing it so often. :D I happened to know the steps off the top of my head so I thought I'd drop a comment.

+3

hey the mod came in for the clutch (: I wish i had the time to have given the most detailed answer, but its not problem we all learn a little more everyday

+3

Schindlabua there is some problem when I compiled the program. It says: Cannot create temporary file in C:\....\AppData\Local\Temp: Permission denied Could you please help me further?

+3

Its easy to install GCC on your windows machine. Just download TDM Gcc compiler here is a link to it. https://sourceforge.net/projects/tdm-gcc/ Once you install it you are good to go. Make your C program and save it as .C extension. Then open Command prompt by typing cmd on keyboard. Suppose you have created hello.C as your file name in Documents folder.Then do the following steps. Your cmd prompt will first have default location set as Example: C:/Users/Username/ then change its directory by typing "cd you c file location" like this- cd documents then its path will change. C:/Users/Username/Documents/ then type gcc -o hello hello.c This will compile the file successfully if it doesnot contain any error. Then it will create an executable file hello.exe in your documents folder,then type hello and press enter and you will able to run your code.

+3

Harsh Singh Thanks Harsh! but could you please help me with the "Permission Denied" error as I mentioned in the previous comment?

+3

thanks Harsh Singh hope this works.. will disturb you again if it doesn't.. if you don't mind 😋

+2

Schindlabua thanks a ton!

+2

oh btw once you create some teat code and need to run it you will need to open up your command prompt and navigate to the folder which you have the code stored and run the code (google how). When it runs it’ll create an executable named “a” and you will run that executable using ./a and it will execute your code

+2

and no problem (:

+2

Richard Johnson thanks Richard for sharing your knowledge.. I am really grateful 😊

+2

Richard Johnson Never mind Richard! We all learn from each other... and that is why its such a great community!

+2

What you can do is open run 1. Delete temp files and also type %temp% and delete this also and try to run the whole process again. 2. https://youtu.be/foHKXLemWaQ watch this video might help you.

+2

Yeah sure..In that way I will also learn how to solve this type of errors if encountered in future .😊

+2

Hi Infinity, sorry for replying late. I'm not familiar with this issue but a quick google search said that you can either: - Try running the command prompt as an administrator - Set the TEMP and TMP environment variables (in the same window you changed PATH) to some folder you know you can write to. People on several forums created a folder "C:\tmp" and pointed TEMP and TMP there. It's a temp folder so it's just stuff that gcc needs while its compiling and it is useless afterwards.

+1

Infinity Best of luck, and you're welcome : )

+1

Under Windows XP / Vista / 7 / 8.x / 10 section, click the link with mingw-setup(highlighted row) either from Sourceforge.net or FossHub. Open the Code::Blocks Setup file and follow the instructions (Next > I agree > Next > Install); you don’t need to change anything. This installs the Code::Blocks with gnu gcc compiler, which is the best compiler to start with for beginners.Now, open Code::Blocks and go to File > New > Empty file (Shortcut: Ctrl + Shift + N) Write the C code and save the file with .c extension. To save the file, go to File > Save (Shortcut: Ctrl + S). Important: The filename should end with a .cextension, like: hello.c, your-program-name.c To run the program, go to Build > Build and Run(Shortcut: F9). This will build the executable file and run it. If your program doesn’t run and if you see error message "can't find compiler executable in your search path(GNU GCC compiler)", go to Settings > Compiler > Toolchain executables and click Auto-detect. This should solve the issue in most cases.