Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUILD] OTLP GRPC exporter fails to build with non default GRPC install #2139

Closed
marcalff opened this issue May 16, 2023 · 1 comment · Fixed by #2097
Closed

[BUILD] OTLP GRPC exporter fails to build with non default GRPC install #2139

marcalff opened this issue May 16, 2023 · 1 comment · Fixed by #2097
Labels
bug Something isn't working

Comments

@marcalff
Copy link
Member

marcalff commented May 16, 2023

Using the OTLP GRPC exporter.

GRPC is installed in a non default location, for example /opt/grpc-1.46.4

In CMake,

gRPC_DIR is set to /opt/grpc-1.46.4/lib/cmake/grpc

During the build:

malff@localhost.localdomain:build-otelcpp-grpc> make
Consolidate compiler generated dependencies of target opentelemetry_proto
[  0%] Building CXX object CMakeFiles/opentelemetry_proto.dir/generated/third_party/opentelemetry-proto/opentelemetry/proto/collector/trace/v1/trace_service.grpc.pb.cc.o
In file included from /home/malff/CODE/MARC_GITHUB/build-otelcpp-grpc/generated/third_party/opentelemetry-proto/opentelemetry/proto/collector/trace/v1/trace_service.grpc.pb.cc:6:
/home/malff/CODE/MARC_GITHUB/build-otelcpp-grpc/generated/third_party/opentelemetry-proto/opentelemetry/proto/collector/trace/v1/trace_service.grpc.pb.h:25:10: fatal error: 'grpcpp/impl/codegen/async_generic_service.h' file not found
#include <grpcpp/impl/codegen/async_generic_service.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

C++ code is properly generated from protobuf files.

The generated C++ code fails to build, because GRPC headers can not be found, as they are in a non default location, not added in the makefiles.

Suggested fix:

diff --git a/cmake/opentelemetry-proto.cmake b/cmake/opentelemetry-proto.cmake
index 1aa1ba03..7addca8b 100644
--- a/cmake/opentelemetry-proto.cmake
+++ b/cmake/opentelemetry-proto.cmake
@@ -285,6 +285,10 @@ else() # cmake 3.8 or lower
   target_link_libraries(opentelemetry_proto INTERFACE ${Protobuf_LIBRARIES})
 endif()
 
+if(WITH_OTLP_GRPC)
+  target_link_libraries(opentelemetry_proto PUBLIC gRPC::grpc++)
+endif()
+
 if(BUILD_SHARED_LIBS)
   set_property(TARGET opentelemetry_proto PROPERTY POSITION_INDEPENDENT_CODE ON)
 endif()
@marcalff marcalff added the bug Something isn't working label May 16, 2023
@owent
Copy link
Member

owent commented May 17, 2023

The generated grpc codes in opentelemetry_proto are splited into opentelemetry_proto_grpc in #2097 .We can not link gRPC::grpc++ into opentelemetry_proto directly on ELF platform, but we can include the INTERFACE_INCLUDE_DIRECTORIES of gRPC::grpc++ in opentelemetry_proto_grpc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants