If you are running Windows:
-
Go to the Cygwin installation page to download the installer that suits your machine.
Please note that the installers are different for 32-bit and 64-bit machines.
-
Install the Cygwin following the video here.
If you are running Ubuntu:
-
The commands you might be looking for are:
sudo apt-get install build-essential
sudo apt-get install g++
If you are running OS X:
-
Install homebrew by executing the following command in the Terminal:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
-
Run:
brew install gcc48
Note that the default version of gcc installed by homebrew may be 5.x, but our lab will use gcc 4.8.
Hello World with g++
-
Create the following Hello World program hello-world.cpp
#include<iostream>
using namespace std;
int main (int argc, char **argv)
{
cout << "Hello World!! " << endl;
return 0;
}
-
Compile and run by executing:
> g++ -o hello-world hello-world.cpp
(Linux or OS X)
> g++ -o hello-world.exe hello-world.cpp
(Windows)