Skip to content

otlp_http_client.cc compilation error #1287

@sirzooro

Description

@sirzooro

Describe your environment
OS: CentOS Stream release 8
Compiler: gcc (GCC) 10.3.1 20210422 (Red Hat 10.3.1-1)
OpenTelemetry libs from today's main branch

Steps to reproduce

cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=ON -DWITH_OTLP=ON -DWITH_OTLP_GRPC=OFF -DWITH_ZPAGES=ON ..
cmake --build . --target all

What is the expected behavior?
Compilation ends successfully.

What is the actual behavior?

[ 89%] Building CXX object exporters/otlp/CMakeFiles/opentelemetry_exporter_otlp_http_client.dir/src/otlp_http_client.cc.o
/build/otlp/opentelemetry-cpp/exporters/otlp/src/otlp_http_client.cc: In function ‘std::string opentelemetry::v1::exporter::otlp::{anonymous}::BytesMapping(const string&, const google::protobuf::FieldDescriptor*, opentelemetry::v1::exporter::otlp::JsonBytesMappingKind)’:
/build/otlp/opentelemetry-cpp/exporters/otlp/src/otlp_http_client.cc:315:40: error: parameter 1 of ‘void google::protobuf::Base64Escape(google::protobuf::StringPiece, std::string*)’ has incomplete type ‘google::protobuf::StringPiece’
  315 |         google::protobuf::Base64Escape(bytes, &base64_value);
      |                                        ^~~~~
/build/otlp/opentelemetry-cpp/exporters/otlp/src/otlp_http_client.cc:31:50: note:   declared here
   31 | LIBPROTOBUF_EXPORT void Base64Escape(StringPiece src, std::string *dest);
      |                                      ~~~~~~~~~~~~^~~
/build/otlp/opentelemetry-cpp/exporters/otlp/src/otlp_http_client.cc:322:38: error: parameter 1 of ‘void google::protobuf::Base64Escape(google::protobuf::StringPiece, std::string*)’ has incomplete type ‘google::protobuf::StringPiece’
  322 |       google::protobuf::Base64Escape(bytes, &base64_value);
      |                                      ^~~~~
/build/otlp/opentelemetry-cpp/exporters/otlp/src/otlp_http_client.cc:31:50: note:   declared here
   31 | LIBPROTOBUF_EXPORT void Base64Escape(StringPiece src, std::string *dest);
      |                                      ~~~~~~~~~~~~^~~
gmake[2]: *** [exporters/otlp/CMakeFiles/opentelemetry_exporter_otlp_http_client.dir/build.make:76: exporters/otlp/CMakeFiles/opentelemetry_exporter_otlp_http_client.dir/src/otlp_http_client.cc.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:4169: exporters/otlp/CMakeFiles/opentelemetry_exporter_otlp_http_client.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2

Additional context
I have fixed this by adding #include "google/protobuf/stubs/stringpiece.h" after other protobuf includes in otlp_http_client.cc. After this change compilation ended successfully and all tests passed.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions