This work is licensed under a
Creative Commons Attribution-ShareAlike 4.0 International License
A quick summary of some of the options for installing a C compiler on your computer.
There are two (related) options:
Install Apple’s Xcode
This requires a free Apple developer account, is a huge download, and unpacks into twice that much stuff, most of which you won’t use unless you’re also a macOS/iOS developer (and probably not even then). You will (probably) also need to run it at least once to “Install additional required components” even if you don’t intend to use the Xcode IDE.
Install only the Apple Developer Command Line Tools (CLT)
This still requires a free Apple developer account, but is a much smaller download. If you plan to work from the Terminal or using an IDE other than Xcode, this might be enough for you.
I found the following site informative: How to Install Xcode Command Line Tools on a Mac. Your mileage may vary.
After installing, launch the Terminal application and type “cc --version” without the quotes (“cc” for “C compiler”) followed by Return:
cc --version
If it says “command not found,” then the compiler is not properly installed.
Note that Apple’s compiler is actually a version of Clang, which is part of LLVM. You can tell this from the output of “cc --version”:
% cc --version
Apple clang version 14.0.3 (clang-1403.0.22.14.1)
...
Apple also makes the name “gcc” an alias for “clang” since many programs and packages developed by the open software community assume that the compiler is named “gcc” (the “GNU Compiler Collection”). This almost certainly doesn’t matter to you, especially for CSC173. But there are ways to install the “real” gcc if you need it: Homebrew, MacPorts, ...)
There are two options:
Install MinGW (detailed information follows)
Install Cygwin (minimal information follows)
MinGW is the “Minimalist GNU for Windows” project, where “GNU” refers to the GNU Project of the Free Software Foundation (FSF). You can (and should) read up about them. MinGW is a collection of developer tools for Windows based on gcc (the “GNU Compiler Collection”).
The good news is that there are two versions of MinGW to choose from.
The bad news is that there are two versions of MinGW to choose from.
The really bad news is that neither version of MinGW is easy to install.
Wikipedia | Original home | “New” home
Link on the homepage to the “Downloads” tab is broken. Nice.
The Documentation link works and takes you to various setup guides and other docs. Like for example: HOWTO Set Up the MinGW (GCC) Compiler Suite — a Guide for New Users. However the “get setup” link did not work for me... (July 2023)
Here are some instructions from earlier times in the hope that they might be helpful to you.
The short story is to download “mingw-get-setup.exe” from this link: https://sourceforge.net/projects/mingw/files/Installer/mingw-get-setup.exe/download (Yes, that file is from 2013. Go figure.)
Double-click the downloaded file (probably in your Downloads folder) to start the installer.
Accept all the default settings and click “Continue” to do the installation.
“Ensure on the left that Basic Setup is highlighted. Click the three boxes indicated below: mingw32-base, mingw32-gcc=g++, msys-base. After clicking each, select Mark for selection.”
The guide goes on to describe what to do next, namely closing the MinGW Installation Manager (which is a weird thing to do) and dealing with the resulting dialogs: Review Changes, Apply. Check it out. I hope it helps.
The installer told me that MinGW was previously installed (which it wasn’t), but telling it to “Reinstall” worked fine.
You may delete mingw-get-setup.exe after the installation is complete.
After installing, launch the Command shell (type “command” into the Start menu search field to find it) and type:
c:\MinGW\bin\gcc --version
If it says “not recognized as an internal or external command,” then MinGW was not properly installed.
If that works, try
gcc --version
If it says “not recognized as an internal or external command,” then MinGW is installed but you didn’t set your Path environment variable properly. Check out the instructions from ICI.
Amazingly, there are no download links or setup instructions on the home page so far as I can tell.
Hang on. Click on the “three-line” or “hamburger” icon in the top-left corner of the page to reveal a menu that includes “Downloads” and Support".
From the “Downloads” page, I literally cannot tell you what to download nor how to install it and set it up.
The Support page is clearly not for mere mortals and refers you to a sourceforge site for “Documentation.”
The General Usage Instructions seems to be the best starter documentation there is. Unfortunately it is also not really for mere mortals.
The SourceForge Downloads area for MinGW-w64 has many files under “Toolchains targetting Win32” and “Toolchains targetting Win64.” None of them are recent. The link entitled “MinGW-W64 Online Installer” might be what you need (links to “Toolchains targetting Win32/Personal Builds/mingw-builds/installer/mingw-w64-install.exe”).
Cygwin is “a large collection of GNU and Open Source tools which provide functionality similar to a Linux distribution on Windows.”
I’m sorry but I don’t have detailed instructions for this one. But you can find more information here: Installing and Updating Cygwin Packages.
Many Linux distributions come with a C compiler already installed. Some don’t. If you type “gcc” in a terminal window and it says “command not found” or something, then you need to install it using your distribution’s package manager.
Of course, this being the world of free software, there is no One Package Manager to Rule Them All, and different distributions use different package managers. But if you are a linux user, you probably know about your package manager. Or perhaps you use it through some graphical application.
However you do it, you probably need at least the “gcc,” “gdb,” and “make” packages (“valgrind” also very useful). As an example, in the current version of Fedora Linux and its (current) package manager “dnf,” you would type:
dnf install gcc gdb make valgrind
Note that you might need to include “sudo” at the front of that command in order to install with superuser (“administrator”) privileges.
You should then have those tools available from your shell (terminal), as well as for use in graphical IDEs such as Eclipse.