CUEH

Development Environment Guides

Installing C++

Installing C++

As part of the programming module you study on the course, you will be tasked with using the C++ programming language to complete lab activities.

In this guide, you shall be taken through the journey of installing C++ for the macOS operating system.

Downloading and Installing C++

By default, the macOS environment will not have the C++ compiler installed. Installing C++ is relatively straight forward in macOS, and requires installing a package using the command-line interface (CLI). To install the C++ compiler, you will need to use the xcode-select command, with the install flag:

$ xcode-select --install

When this command is entered in the CLI, you will be met with a question similar to the one shown in the screenshot in Figure 1.

Figure 1

Figure 1. Installing the C++ Compiler on a macOS system.

This will ask whether you would like to install the command-line developer tools. In this instance, you will want to click on the button labelled Install to continue with the installation. You will then be met with the license agreement for installing these tools, you will need to click on the button labelled Agree to proceed.

This will then begin the installation process and download the necessary software from the Apple servers. This process may take some time, depending upon your internet connection speed. Once the installation process has completed, you will be met with a similar pop as the one shown in Figure 2.

Figure 2

Figure 2. Completed Installation of the C++ Compiler on a macOS system.

Checking the C++ Installation

To confirm that everything is working as expected, you will need to perform a quick check using the command-line interface. To perform this check, open Terminal by searching for Terminal in the Launchpad screen as shown in Figure 3.

Figure 3

Figure 3. Searching for Terminal in the Launchpad Screen.

With the command-line interface open, you can type the command g++ -v and the C++ compiler should be executed and return the current version number, shown in Figure 4.

Figure 4

Figure 4. The C++ Compiler in the Terminal Window.

Conclusion

That is the end of this guide on installing C++ and if you have followed all the necessary steps correctly, you should have a fully functional implementation of the C++ compiler which will enable you to complete any necessary C++ programming-based activities and assignments you will participate with on this course.

Mistakes or Problems?

If you have spotted any errors or issues within this tutorial, you can e-mail Dr Ian Cornelius. Ensure to include in your message a description of the error/issue and a possible resolution. Also do not forget to include a URL to the page with the issue/error.