+ 11

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?

21st Aug 2018, 1:01 PM
Infinity
Infinity - avatar
25 Réponses
+ 9
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.
21st Aug 2018, 4:26 PM
Schindlabua
Schindlabua - avatar
+ 8
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.
21st Aug 2018, 4:04 PM
Richard Johnson
Richard Johnson - avatar
+ 5
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/
21st Aug 2018, 4:05 PM
Ipang
21st Aug 2018, 4:24 PM
Infinity
Infinity - avatar
+ 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.
21st Aug 2018, 4:38 PM
Schindlabua
Schindlabua - avatar
+ 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
21st Aug 2018, 4:32 PM
Richard Johnson
Richard Johnson - avatar
+ 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?
21st Aug 2018, 4:50 PM
Infinity
Infinity - avatar
+ 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.
21st Aug 2018, 6:22 PM
Harsh Singh
+ 3
Harsh Singh Thanks Harsh! but could you please help me with the "Permission Denied" error as I mentioned in the previous comment?
21st Aug 2018, 6:30 PM
Infinity
Infinity - avatar
+ 3
thanks Harsh Singh hope this works.. will disturb you again if it doesn't.. if you don't mind 😋
21st Aug 2018, 6:38 PM
Infinity
Infinity - avatar
+ 2
Schindlabua thanks a ton!
21st Aug 2018, 4:28 PM
Infinity
Infinity - avatar
+ 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
21st Aug 2018, 4:28 PM
Richard Johnson
Richard Johnson - avatar
+ 2
and no problem (:
21st Aug 2018, 4:29 PM
Richard Johnson
Richard Johnson - avatar
+ 2
Richard Johnson thanks Richard for sharing your knowledge.. I am really grateful 😊
21st Aug 2018, 4:29 PM
Infinity
Infinity - avatar
+ 2
Richard Johnson Never mind Richard! We all learn from each other... and that is why its such a great community!
21st Aug 2018, 4:34 PM
Infinity
Infinity - avatar
+ 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.
21st Aug 2018, 6:36 PM
Harsh Singh
+ 2
Yeah sure..In that way I will also learn how to solve this type of errors if encountered in future .😊
21st Aug 2018, 6:40 PM
Harsh Singh
+ 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.
21st Aug 2018, 7:27 PM
Schindlabua
Schindlabua - avatar
+ 1
Infinity Best of luck, and you're welcome : )
21st Aug 2018, 4:25 PM
Ipang
+ 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.
22nd Aug 2018, 6:58 AM
Jokerkarthi
Jokerkarthi - avatar