Google Cloud Storage C++ Client 2.10.1
A C++ Client Library for Google Cloud Storage
No Matches
Google Cloud Storage C++ Client Library

The Google Cloud Storage (GCS) C++ Client library offers types and functions access GCS from C++ applications. It offers full access to the GCS API, including operations to list, read, write, and delete GCS objects and buckets. The library also provides functions to modify the IAM permissions on buckets, read and modify the metadata associated with objects and buckets, configure encryption keys, configure notifications via Cloud Pub/Sub, and change the access control list of object or buckets.


The following "Hello World" program should give you a taste of this library. This program is also used to illustrate how to incorporate the library into your project.

#include "google/cloud/storage/client.h"
#include <iostream>
int main(int argc, char* argv[]) {
if (argc != 2) {
std::cerr << "Missing bucket name.\n";
std::cerr << "Usage: quickstart <bucket-name>\n";
return 1;
std::string const bucket_name = argv[1];
// Create aliases to make the code easier to read.
namespace gcs = ::google::cloud::storage;
// Create a client to communicate with Google Cloud Storage. This client
// uses the default configuration for authentication and project id.
auto client = gcs::Client();
auto writer = client.WriteObject(bucket_name, "quickstart.txt");
writer << "Hello World!";
if (!writer.metadata()) {
std::cerr << "Error creating object: " << writer.metadata().status()
<< "\n";
return 1;
std::cout << "Successfully created object: " << *writer.metadata() << "\n";
auto reader = client.ReadObject(bucket_name, "quickstart.txt");
if (!reader) {
std::cerr << "Error reading object: " << reader.status() << "\n";
return 1;
std::string contents{std::istreambuf_iterator<char>{reader}, {}};
std::cout << contents << "\n";
return 0;

Building and Installing

  • Packaging maintainers or developers who prefer to install the library in a fixed directory (such as /usr/local or /opt) should consult the packaging guide.
  • Developers who prefer using a package manager such as vcpkg, or Conda, should follow the instructions for their package manager.
  • Developers wanting to use the libraries as part of a larger CMake or Bazel project should consult the quickstart guide.
  • Developers wanting to compile the library just to run some examples or tests should read the project's top-level README.
  • Contributors and developers to google-cloud-cpp should consult the guide to set up a development workstation.

Next Steps