In the past week I have been asked a countless number of times how to install GCC ( GNU Compiler Collection ). I have been using it in my C Video Tutorial.
I show you how to install GCC on Windows as well as on a Mac in the video below. Not only did I make a video, but I also have everything listed step-by-step below after the video. If you have any trouble setting this up, leave a comment below and I’ll try to help.
If you like videos like this, it helps to tell Google+ with a click here [googleplusone]
How to Install GCC on Windows
1. Download the MinGW Installer here ( Click the green download button )
2. Run the Installer
3. Pick which ever languages you want to compile as the installer runs. Make sure you save MinGW in C:\MinGW though to avoid a ton of problems
4. Open the Command Prompt ( It is in the Accessories Folder in Start )
5. Add MinGW to the Path either by:
a. Type set PATH=C:\MinGW\bin;%PATH%
b. Or, go to Control Panel – System Security – System – Advanced Settings. Then click Environment Variables and click on PATH and Edit. Then add this to the end and save ;C:\MinGW\bin
6. In the Command Prompt type gcc -v to see if it worked. ( You may have to restart the Command Prompt )
How to Install GCC on Mac
It is very easy to install GCC 4.8.1 on a Mac if you have Mac Ports installed. Here are the steps to set everything up:
1. Go to MacPorts and install it by downloading the DMG and installing it. Make sure you pick the right version based on your operating system version.
2. Open your Mac Terminal ( Applications – Utilities – Terminal )
3. Update MacPorts by typing this in the terminal sudo port selfupdate
4. Install GCC 4.8 by typing this in the terminal sudo port install gcc48 ( This can take a while to install )
5. Now change the default version of GCC by typing this in the terminal sudo port select –set gcc mp-gcc48
6. Now type this in the terminal hash gcc
7. Test if you are using the new version of GCC by typing this in the terminal gcc -v
If you see version 4.8 in what follows, congratulations you have the updated version of GCC and you are ready to start writing C11 programs.
Hi Derek,
I had a different gcc version installed many months ago. Could this be why I’m not getting the version 4.8 after following all of these steps on my Macbook Pro?
Doug
That could be. Make sure you point forward the right version in your path and that should fix it.
Derek, installing on a mac. everything worked fine until I got to the terminal command:
sudo port select -set gcc mp-gcc48
I get the following error:
Usage: port
[-bcdfknopqRstuvy] [-D portdir] [-F cmdfile] action [privopts] [actionflags]
[[portname|pseudo-portname|port-url] [@version] [+-variant]… [option=value]…]…
“port help” or “man 1 port” for more information.
Can you offer any help?
You should find your answer here https://guide.macports.org/
Did you figure out the issue? I had the same problem and cannot resolve
Hey buddy,
I’ve run into the same issue. Did you manage to solve it?
Thanks!
set should be preceded by 2 hyphens like –set. It helped in my case
I have the same problem and I didnt find anything on the guide hope someone can help fix this
try like that
sudo port select –set gcc mp-gcc48
Hey mate,
appreciate video, very helpful.
However, I am installing on windows and it seems to all have worked ..except the ending and checking.
when I type gcc -v into command it shows its installed etc
I can go through dir to where I saved the files…
my problem is… you click on a “testing” doc? which I assume you made some lil code in notepad earlier and saved it there ..
I made one called “motto.cpp” in notepad but when I try to do your last step of typing in “gcc motto.cpp” I get an error message.
this was the code I saved…
#include
int main()
{
std::cout <gcc Motto.cpp
motto.cpp:5:14: warning: missing terminating ” character [enabled by default]
std::cout << "Solidum petit in profundis!\n;
motto.cpp:5:1 error: missing terminating " character
std::cout << "Solidum petit in profundis!\n;
motto.cpp: In function 'int main()':
motto.cpp:6:1: error: expected primary-expression before 'return'
return 0;
motto.cpp:6:1: error: expected ';' before 'return'
please help me if you can???? so confused whats going wrong?
email me back …. mboyman@hotmail.com
Hey,
Change std::cout << "Solidum petit in profundis!\n; to std::cout << "Solidum petit in profundis!\n"; The "expected primary-expression" error normally occurs if the return type is wrong. expected ';' before 'return' probably occurred because a semi-colon is missing I hope that helps