We have a need to use Google's GCS C++ client library. We've downloaded the library (version 1.23.0) and all of its dependencies. We've built those libraries. I am attempting to modify one of the sample programs that Google supplies along with their GCS C++ library. Background: we're running on RHEL 7, gcc 7.4.0, GCS C++ 1.23.0 and building using the std=C++11 keyword.
The sample program creates credentials and a client handle. It then uses that handle to exercise various API methods in the GCS C++ library.
The relevant portion of the sample code I have follows:
std::string authBuffer = ""; //Deleted actual key for obvious reasons
// The credentials are successfully created:
auto creds = gcs::oauth2::CreateServiceAccountCredentialsFromJsonContents( authBuffer );
// As is the client handle:
gcs::Client client=gcs::Client(gcs::ClientOptions(*creds));
// This code will build and run without error:
auto writer = client.WriteObject(std::string("temp"), "quickstart.txt");
writer << "Hello world!";
writer.Close();
// However this is the problem line of code:
auto bucketReader = client.ListBucketsForProject( std::string( "my_project" ) );
As stated in the comments above, the bucket reader code fails to link. I encounter the following link error:
In function `google::cloud::v1::StatusOr<google::cloud::storage::v1::BucketMetadata>::StatusOr(google::cloud::v1::Status)': <first part of path snipped>/gc-cpp/google-cloud-cpp-1.23.0/install6/include/google/cloud/status_or.h:118: undefined reference to `google::cloud::v1::internal::ThrowInvalidArgument(char const*)'
sample.o: In function `_ZNK4absl14lts_2020_09_2316variant_internal17PerformVisitationIZN6google5cloud2v18internal11StreamRangeINS4_7storage2v114BucketMetadataEE4NextEvE13UnpackVariantJNS0_7variantIJNS5_6StatusESA_EEEEE3RunIJLm0EEJLm18446744073709551615EEEEvSt17integral_constantIbLb1EENS0_16integer_sequenceImJXT_EEEEDpSI_ImXT0_EE':
<first part of path snipped>/abseil-cpp/abseil-cpp-20200923.3/install6/include/absl/types/internal/variant.h:942: undefined reference to `absl::lts_2020_09_23::variant_internal::ThrowBadVariantAccess()'
All of which is a bunch of gooblty-gook upon first glance. I mean we all know what an undefined reference is, but why is this happening within the GCS C++ library code? It's almost as if Google is utilizing some type of macro build magic in order to tell me that I have malformed code of some sort. I'm not certain where I am going awry though.
Interestingly, if I comment the bucket reader statement out, then the program will build and run without incident. I can see the new quickstart.txt file appear in the bucket within the project in my GCS account via a web browser.
So what gives with this bucket reader business? If coryan is reading this, I'd appreciate feedback. I decided to use the GCS C++ library based in part on his previous feedback in a separate SO question. Thanks!
Aucun commentaire:
Enregistrer un commentaire