Setting up a C++ development environment Stay organized with collections Save and categorize content based on your preferences.
This tutorial shows how to prepare your local machine forC++ development, including developing C++ apps that run on Google Cloud.
If you already have a development environment set up, seeC++ and Google Cloud to get an overview of how to run C++ apps on Google Cloud.
Objectives
- Install asupported 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 theguide for the operating system you're running in your development environment,macOS, Windows, or Linux.
macOS
You can get a C++ compiler by installingXcode's command-line tools.
xcode-select--installAfter the installation is complete, verify that your compiler isavailable as
c++:c++--version
Windows
To install a C++ compiler in a Windows environment, download theMicrosoft's "Visual Studio" from theVisual Studio website.This will download a full IDE, including an editor, debugger and buildsystems.
To access your C++ compiler follow the C++ section in Visual Studio'sGetting Started guide.
Linux
Most (if not all) Linux distributions includeGCC as their primary C++ compiler. Many Linux distributions also includeCLang as an alternative C++ compiler. The C++ client libraries support both.
To install C++ in a Linux environment, install the appropriate packagesfor your distribution. For Debian and Ubuntu, this package isg++.
Install these packages using the following commands:
sudoaptupdatesudoaptinstallg++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 thatsupports the Cloud Client Libraries for C++. The client libraries support multiplesuch build systems and package managers.
CMake with vcpkg
Your operating system may provide packages forCMake installed. If it does not, install it from theCMake download page
To install vcpkg, seeGet Started with vcpkg
CMake with Conda
Your operating system may provide packages forCMake installed. If it does not, install it from theCMake download page
To install Conda, see theInstallation section in Conda's User Guide.
Bazel
- To install Bazel, seeInstalling Bazel
Other
If you need to use a different build system or package manager the C++ clientlibraries repository include instructions tobuild from source.
Install an editor
There are manyeditors and IDEs with C++ support. Pick one that fits your needs. Consider these features asyou make your selection:
- Fully integrated debugging capabilities
- Syntax highlighting
- Code completion
Install the Google Cloud CLI
TheGoogle Cloud CLI is a set of tools for Google Cloud. It contains thegcloud andbq command-line tools used to access Compute Engine, Cloud Storage,BigQuery, and other services from the command line. You can run thesetools interactively or in your automated scripts.
Install the Cloud Client Libraries for C++
TheCloud Client Libraries for C++ is the idiomatic way for C++ developers to integrate withGoogle Cloud services, such as Spanner and Cloud Storage.For example, to install the package for an individual API, such as theCloud Storage API, do the following:
CMake with vcpkg
Add
google-cloud-cppas dependency to yourvcpkg.jsonfile:{"name":"setup-cpp-vcpkg","version-string":"unversioned","description":"Setting up C++ for Google Cloud with CMake and vcpkg","dependencies":[{"name":"google-cloud-cpp","default-features":false,"features":["storage"]}]}Edit your
CMakeLists.txtfile to require the libraryfind_package(google_cloud_cpp_storageREQUIRED)Add this dependency to your targets
target_link_libraries(hello_worldPUBLICgoogle-cloud-cpp::storage)Configure CMake using the vcpkg toolchain. This will automaticallydownload, and compile
google-cloud-cppand its dependencies.cmake-S.-B[builddirectory]\-DCMAKE_TOOLCHAIN_FILE=[vcpkglocation]/scripts/buildsystems/vcpkg.cmake
CMake with Conda
Install the dependencies using Conda:
condaconfig--addchannelsconda-forgecondaconfig--setchannel_prioritystrictcondainstall-y-cconda-forgecmakeninjacxx-compilergoogle-cloud-cpplibgoogle-cloudEdit your
CMakeLists.txtfile to require the libraryfind_package(google_cloud_cpp_storageREQUIRED)Add this dependency to your targets
target_link_libraries(hello_worldPUBLICgoogle-cloud-cpp::storage)Configure CMake within your Conda environment..
cmake-S.-B[builddirectory]
Bazel
In your
WORKSPACEfile add the follow command to download theCloud Client Libraries for C++ source code:load("@bazel_tools//tools/build_defs/repo:http.bzl","http_archive")http_archive(name="google_cloud_cpp",sha256="db69dd73ef4af8b2e816d80ded04950036d0e0dccc274f8c3d3ed1d7f5692a1b",strip_prefix="google-cloud-cpp-2.32.0",url="https://github.com/googleapis/google-cloud-cpp/archive/v2.32.0.tar.gz",)In your
WORKSPACEfile call the Starlark functions to load recursivedependencies:load("@google_cloud_cpp//bazel:workspace0.bzl","gl_cpp_workspace0")gl_cpp_workspace0()load("@google_cloud_cpp//bazel:workspace1.bzl","gl_cpp_workspace1")gl_cpp_workspace1()load("@google_cloud_cpp//bazel:workspace2.bzl","gl_cpp_workspace2")gl_cpp_workspace2()load("@google_cloud_cpp//bazel:workspace3.bzl","gl_cpp_workspace3")gl_cpp_workspace3()load("@google_cloud_cpp//bazel:workspace4.bzl","gl_cpp_workspace4")gl_cpp_workspace4()load("@google_cloud_cpp//bazel:workspace5.bzl","gl_cpp_workspace5")gl_cpp_workspace5()In your
BUILDfile use the Cloud Storage library:cc_binary(name="hello_world",srcs=["hello_world.cc"],deps=["@google_cloud_cpp//:storage"],)
Set up authentication
To use the Cloud Client Libraries in a local development environment, setup Application Default Credentials.
If you're using a local shell, then create local authentication credentials for your user account:
gcloudauthapplication-defaultlogin
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
For more information, seeAuthenticate for using client libraries.
What's next
- Get more information aboutauthentication.
- Learn more aboutC++ on Google Cloud.
- Browse thedocumentation for Google Cloud products.
- Clone theC++ samples repository from GitHub.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-02-19 UTC.