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.
After the installation is complete, verify that your compiler is
available as c++:
c++--version
Windows
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.
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.
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:
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 that
supports the Cloud Client Libraries for C++. The client libraries support multiple
such build systems and package managers.
CMake with vcpkg
Your operating system may provide packages for
CMake
installed. If it does not, install it from the
CMake download page
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
Install the Google Cloud CLI
The Google Cloud CLI
is a set of tools for Google Cloud. It contains the
gcloud
and bq
command-line tools used to access Compute Engine, Cloud Storage,
BigQuery, and other services from the command line. You can run these
tools interactively or in your automated scripts.
Install the Cloud Client Libraries for C++
The Cloud Client Libraries for C++
is the idiomatic way for C++ developers to integrate with
Google Cloud services, such as Spanner and Cloud Storage.
For example, to install the package for an individual API, such as the
Cloud Storage API, do the following:
CMake with vcpkg
Add google-cloud-cpp as dependency to your vcpkg.json file:
{"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.txt file to require the library
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-21 UTC."],[[["\u003cp\u003eThis guide provides instructions for setting up a local C++ development environment compatible with Google Cloud, covering operating systems such as macOS, Windows, and Linux.\u003c/p\u003e\n"],["\u003cp\u003eThe tutorial details how to install a C++ compiler and a suitable build system (like CMake, Conda, or Bazel) to effectively manage C++ projects and utilize Cloud Client Libraries.\u003c/p\u003e\n"],["\u003cp\u003eIt explains the process of installing optional components like the Google Cloud CLI and the Cloud Client Libraries for C++, including how to integrate these libraries into your project using different build systems.\u003c/p\u003e\n"],["\u003cp\u003eThe guide includes instructions on how to set up authentication for your C++ applications to access Google Cloud services, specifically using Application Default Credentials.\u003c/p\u003e\n"],["\u003cp\u003eUsers can explore additional resources such as authentication guides, C++ on Google Cloud, Google Cloud product documentation, and a C++ samples repository.\u003c/p\u003e\n"]]],[],null,["# Setting up a C++ development environment\n\nThis tutorial shows how to prepare your local machine for\n[C++](https://isocpp.org/)\ndevelopment, including developing C++ apps that run on Google Cloud.\n\nIf you already have a development environment set up, see\n[C++ and Google Cloud](/cpp)\nto get an overview of how to run C++ apps on Google Cloud.\n\nObjectives\n----------\n\n- Install a [supported version of C++](/cpp/docs/supported-cpp-versions) compatible with Google Cloud.\n- Install a C++ build system.\n- Install an editor (optional).\n- Install the Google Cloud CLI (optional).\n- Install the Cloud Client Libraries for C++ (optional).\n- Set up authentication.\n\nInstalling C++\n--------------\n\nC++'s installation instructions vary by operating system. Follow the\nguide for the operating system you're running in your development environment,\nmacOS, Windows, or Linux. \n\n### macOS\n\n1. You can get a C++ compiler by installing\n [Xcode's command-line tools](https://developer.apple.com/library/content/technotes/tn2339/_index.html).\n\n xcode-select --install\n\n2. After the installation is complete, verify that your compiler is\n available as `c++`:\n\n c++ --version\n\n### Windows\n\n1. To install a C++ compiler in a Windows environment, download the\n Microsoft's \"Visual Studio\" from the\n [Visual Studio website](https://visualstudio.microsoft.com/vs/features/cplusplus/).\n This will download a full IDE, including an editor, debugger and build\n systems.\n\n2. To access your C++ compiler follow the C++ section in Visual Studio's\n [Getting Started](https://visualstudio.microsoft.com/vs/getting-started/)\n guide.\n\n### Linux\n\nMost (if not all) Linux distributions include [GCC](https://gcc.gnu.org/)\nas their primary C++ compiler. Many Linux distributions also include\n[CLang](https://clang.llvm.org/)\nas an alternative C++ compiler. The C++ client libraries support both.\n\n1. To install C++ in a Linux environment, install the appropriate packages\n for your distribution. For Debian and Ubuntu, this package is\n [g++](https://packages.debian.org/stable/devel/g++).\n\n Install these packages using the following commands: \n\n sudo apt update\n sudo apt install g++\n\n2. After the installations are complete, verify that you have `g++`\n installed:\n\n g++ --version\n\nInstall a C++ Build System compatible with Google Cloud\n-------------------------------------------------------\n\nTo use C++ effectively you will want a build system and package manager that\nsupports the Cloud Client Libraries for C++. The client libraries support multiple\nsuch build systems and package managers. \n\n### CMake with vcpkg\n\n1. Your operating system may provide packages for\n [CMake](https://cmake.org/)\n installed. If it does not, install it from the\n [CMake download page](https://cmake.org/download/)\n\n2. To install vcpkg, see\n [Get Started with vcpkg](https://vcpkg.io/en/getting-started.html)\n\n### CMake with Conda\n\n1. Your operating system may provide packages for\n [CMake](https://cmake.org/)\n installed. If it does not, install it from the\n [CMake download page](https://cmake.org/download/)\n\n2. To install Conda, see the\n [Installation section](https://docs.conda.io/projects/conda/en/stable/user-guide/install/index.html)\n in Conda's User Guide.\n\n### Bazel\n\n1. To install Bazel, see [Installing Bazel](https://bazel.build/install)\n\n### Other\n\nIf you need to use a different build system or package manager the C++ client\nlibraries repository include instructions to\n[build from source](https://github.com/googleapis/google-cloud-cpp/blob/main/doc/packaging.md).\n\nInstall an editor\n-----------------\n\nThere are many [editors and IDEs](https://en.wikipedia.org/wiki/Comparison_of_integrated_development_environments#C/C++)\nwith C++ support. Pick one that fits your needs. Consider these features as\nyou make your selection:\n\n- Fully integrated debugging capabilities\n- Syntax highlighting\n- Code completion\n\nInstall the Google Cloud CLI\n----------------------------\n\nThe [Google Cloud CLI](/sdk)\nis a set of tools for Google Cloud. It contains the\n[`gcloud`](/sdk/gcloud)\nand [`bq`](/bigquery/docs/bq-command-line-tool)\ncommand-line tools used to access Compute Engine, Cloud Storage,\nBigQuery, and other services from the command line. You can run these\ntools interactively or in your automated scripts.\n\nInstall the Cloud Client Libraries for C++\n------------------------------------------\n\nThe [Cloud Client Libraries for C++](https://github.com/googleapis/google-cloud-cpp/)\nis the idiomatic way for C++ developers to integrate with\nGoogle Cloud services, such as Spanner and Cloud Storage.\n\nFor example, to install the package for an individual API, such as the\nCloud Storage API, do the following: \n\n### CMake with vcpkg\n\n1. Add `google-cloud-cpp` as dependency to your `vcpkg.json` file:\n\n {\n \"name\": \"setup-cpp-vcpkg\",\n \"version-string\": \"unversioned\",\n \"description\": \"Setting up C++ for Google Cloud with CMake and vcpkg\",\n \"dependencies\": [\n {\"name\": \"google-cloud-cpp\", \"default-features\": false, \"features\": [\"storage\"]}\n ]\n }\n\n2. Edit your `CMakeLists.txt` file to require the library\n\n find_package(google_cloud_cpp_storage REQUIRED)\n\n3. Add this dependency to your targets\n\n target_link_libraries(hello_world PUBLIC google-cloud-cpp::storage)\n\n4. Configure CMake using the vcpkg toolchain. This will automatically\n download, and compile `google-cloud-cpp` and its dependencies.\n\n cmake -S . -B [build directory] \\\n -DCMAKE_TOOLCHAIN_FILE=[vcpkg location]/scripts/buildsystems/vcpkg.cmake\n\n### CMake with Conda\n\n1. Install the dependencies using Conda:\n\n conda config --add channels conda-forge\n conda config --set channel_priority strict\n conda install -y -c conda-forge cmake ninja cxx-compiler google-cloud-cpp libgoogle-cloud\n\n2. Edit your `CMakeLists.txt` file to require the library\n\n find_package(google_cloud_cpp_storage REQUIRED)\n\n3. Add this dependency to your targets\n\n target_link_libraries(hello_world PUBLIC google-cloud-cpp::storage)\n\n4. Configure CMake within your Conda environment..\n\n cmake -S . -B [build directory]\n\n### Bazel\n\n1. In your `WORKSPACE` file add the follow command to download the\n Cloud Client Libraries for C++ source code:\n\n load(\"@bazel_tools//tools/build_defs/repo:http.bzl\", \"http_archive\")\n\n http_archive(\n name = \"google_cloud_cpp\",\n sha256 = \"db69dd73ef4af8b2e816d80ded04950036d0e0dccc274f8c3d3ed1d7f5692a1b\",\n strip_prefix = \"google-cloud-cpp-2.32.0\",\n url = \"https://github.com/googleapis/google-cloud-cpp/archive/v2.32.0.tar.gz\",\n )\n\n2. In your `WORKSPACE` file call the Starlark functions to load recursive\n dependencies:\n\n load(\"@google_cloud_cpp//bazel:workspace0.bzl\", \"gl_cpp_workspace0\")\n\n gl_cpp_workspace0()\n\n load(\"@google_cloud_cpp//bazel:workspace1.bzl\", \"gl_cpp_workspace1\")\n\n gl_cpp_workspace1()\n\n load(\"@google_cloud_cpp//bazel:workspace2.bzl\", \"gl_cpp_workspace2\")\n\n gl_cpp_workspace2()\n\n load(\"@google_cloud_cpp//bazel:workspace3.bzl\", \"gl_cpp_workspace3\")\n\n gl_cpp_workspace3()\n\n load(\"@google_cloud_cpp//bazel:workspace4.bzl\", \"gl_cpp_workspace4\")\n\n gl_cpp_workspace4()\n\n load(\"@google_cloud_cpp//bazel:workspace5.bzl\", \"gl_cpp_workspace5\")\n\n gl_cpp_workspace5()\n\n3. In your `BUILD` file use the Cloud Storage library:\n\n cc_binary(\n name = \"hello_world\",\n srcs = [\"hello_world.cc\"],\n deps = [\"@google_cloud_cpp//:storage\"],\n )\n\nSet up authentication\n---------------------\n\nTo use the Cloud Client Libraries in a local development environment, set\nup Application Default Credentials.\n\n\nIf you're using a local shell, then create local authentication credentials for your user\naccount:\n\n```bash\ngcloud auth application-default login\n```\n\nYou don't need to do this if you're using Cloud Shell.\n\n\nIf an authentication error is returned, and you are using an external identity provider\n(IdP), confirm that you have\n[signed in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\nFor more information, see\n[Authenticate for using client libraries](/docs/authentication/client-libraries).\n\nWhat's next\n-----------\n\n- Get more information about [authentication](/docs/authentication).\n- Learn more about [C++ on Google Cloud](/cpp).\n- Browse the [documentation for Google Cloud products](/products).\n- Clone the [C++ samples repository from GitHub](https://github.com/GoogleCloudPlatform/cpp-samples)."]]