Setting up a C++ development environment

This tutorial shows how to prepare your local machine for C++ development, including developing C++ apps that run on Google Cloud.

If you already have a development environment set up, see C++ and Google Cloud to get an overview of how to run C++ apps on Google Cloud.

Objectives

  • Install a supported version of C++ compatible with Google Cloud.
  • Install a C++ build system.
  • Install an editor (optional).
  • Install the Google Cloud CLI (optional).
  • Install the Cloud Client Libraries for C++ (optional).
  • Set up authentication.

Installing C++

C++'s installation instructions vary by operating system. Follow the guide for the operating system you're running in your development environment, macOS, Windows, or Linux.

macOS

  1. You can get a C++ compiler by installing Xcode's command-line tools.

    xcode-select --install
    
  2. After the installation is complete, verify that your compiler is available as c++:

    c++ --version
    

Windows

  1. To install a C++ compiler in a Windows environment, download the Microsoft's "Visual Studio" from the Visual Studio website. This will download a full IDE, including an editor, debugger and build systems.

  2. To access your C++ compiler follow the C++ section in Visual Studio's Getting Started guide.

Linux

Most (if not all) Linux distributions include GCC as their primary C++ compiler. Many Linux distributions also include CLang as an alternative C++ compiler. The C++ client libraries support both.

  1. To install C++ in a Linux environment, install the appropriate packages for your distribution. For Debian and Ubuntu, this package is g++.

    Install these packages using the following commands:

    sudo apt update
    sudo apt install g++
    
  2. After the installations are complete, verify that you have g++ installed:

    g++ --version
    

Install a C++ Build System compatible with Google Cloud

To use C++ effectively you will want a build system and package manager that supports the Cloud Client Libraries for C++. The client libraries support multiple such build systems and package managers.

CMake with vcpkg

  1. Your operating system may provide packages for CMake installed. If it does not, install it from the CMake download page

  2. To install vcpkg, see Get Started with vcpkg

CMake with Conda

  1. Your operating system may provide packages for CMake installed. If it does not, install it from the CMake download page

  2. To install Conda, see the Installation section in Conda's User Guide.

Bazel

  1. To install Bazel, see Installing Bazel

Other

If you need to use a different build system or package manager the C++ client libraries repository include instructions to build from source.

Install an editor

There are many editors and IDEs with C++ support. Pick one that fits your needs. Consider these features as you make your selection:

  • Fully integrated debugging capabilities
  • Syntax highlighting
  • Code completion