GCC Preparing your environment - learnclang/1-helloworld GitHub Wiki

Rather than try and configure your personal environment, I'll be going through setting up a new environment using a virtual machine. The virtual machine will be running a freshly installed Ubuntu 12.04. This way, there should be little difference between your results and those shown here.

Alternatively, you could skip this part and try to follow along in your current environment. Should you run into trouble, come back and follow the steps below.

[Skip this step ->](GCC Writing hello world)

Getting started

I will be running on a Windows machine, 8.1, running Ubuntu 12.04 on a virtual machine via Oracle VirtualBox, but the same will apply to any of the aforementioned platforms. To follow along, you'll need Virtual Box and the installation disk of Ubuntu, both of which are free.

Make sure you get version 12.04 of Ubuntu if you intend on following along with this tutorial. Next, install Virtual Box and run it.

width=400px

Starting VirtualBox

Choose to create a new virtual machine, using all of the default settings that go with an Ubuntu 64-bit setup. I typically give it a little more memory, such as 2048 mb. Once started, it will ask you for an installation disk. Simply point it to your Ubuntu DVD that you downloaded above.

width=400px

Pick all the default options and go grab a cup of coffee. Once it's done, it should look something like this.

width=400px

Installing the virtual machine utilities (optional)

At first, you'll notice that your cursor lags a little bit and that the refresh rate is close to 12 fps. A virtual machine host such as Virtual Box and VMWare Workstation both ship with drivers for the client that enables various accelerations, mainly to enhance the interactivity of the cursor and refresh rate.

Let's install this now.

  1. In Virtual Box, under Devices
  2. Select Insert Guest Additions CD Image
  3. Ubuntu should prompt you for your password, enter it
  4. Next, it will ask you if you would like to auto-run the CD, click yes
  5. Restart Ubuntu

If for some reason it fails, un-mount the CD and repeat steps 1-4 to try again.

FAQ

The headers for the current running kernel were not found

The installation of the VirtualBox additions might tell you that it's missing some headers, but not to worry, those won't be necessary for this particular tutorial.

That's it, Ubuntu has been installed. Now let's move on to writing the code!

[Next: Writing hello world ->](GCC Writing hello world)