Open maxlein opened 1 month ago
Could you please check whether HAVE_ABSEIL
is in INTERFACE_COMPILE_DEFINITIONS
of opentelemetry-cpp::api
?(located in ${opentelemetry-cpp_DIR}/opentelemetry-cpp-target.cmake
)
It seems otel-cpp's headers are included without HAVE_ABSEIL
, this macro should be defined automaticly by cmake when linking otel-cpp's CONFIG package.
For me it looks like this in this file /usr/lib/cmake/opentelemetry-cpp/opentelemetry-cpp-target.cmake
:
set_target_properties(opentelemetry-cpp::api PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "OPENTELEMETRY_DEPRECATED_SDK_FACTORY;HAVE_ABSEIL;OPENTELEMETRY_STL_VERSION=2023;OPENTELEMETRY_ABI_VERSION_NO=1"
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
INTERFACE_LINK_LIBRARIES "absl::bad_variant_access;absl::any;absl::base;absl::bits;absl::city"
)
And in my app it looks like this now:
#### Tracing Library ####
find_package(opentelemetry-cpp CONFIG REQUIRED)
message(STATUS "Found otel: ${opentelemetry-cpp_DIR}")
#print INTERFACE_COMPILE_DEFINITIONS
message("INTERFACE_COMPILE_DEFINITIONS: ${opentelemetry-cpp_INTERFACE_COMPILE_DEFINITIONS}")
if(NOT DEFINED HAVE_ABSEIL)
message(FATAL_ERROR "HAVE_ABSEIL not defined")
endif(NOT DEFINED HAVE_ABSEIL)
if(NOT DEFINED ${HAVE_ABSEIL})
message(FATAL_ERROR "HAVE_ABSEIL empty")
else ()
message("HAVE_ABSEIL defined as ${HAVE_ABSEIL}")
endif(NOT DEFINED ${HAVE_ABSEIL})
-- Found otel: /usr/lib/cmake/opentelemetry-cpp
INTERFACE_COMPILE_DEFINITIONS:
CMake Error at CMakeLists.txt:35 (message):
HAVE_ABSEIL not defined
Adding add_compile_definitions(HAVE_ABSEIL)
manually to my project cmake file fixes the issue and I can compile
HAVE_ABSEIL
is a C++ macro, not a CMake variable. It should be included using target_link_libraries(tracer_lib PUBLIC ${COMMON_LIBS} ${OPENTELEMETRY_CPP_LIBRARIES})
in your project. Please check whether OPENTELEMETRY_CPP_LIBRARIES
includes opentelemetry-cpp::api
by using message("OPENTELEMETRY_CPP_LIBRARIES=${OPENTELEMETRY_CPP_LIBRARIES}")
. The CMake config file /usr/lib/cmake/opentelemetry-cpp/opentelemetry-cpp-target.cmake
appears to be fine.
Describe your environment Ubuntu 22.04 CMake build
I want to add tracing to my already existing app where we also use and link against grpc/abseil.
Steps to reproduce
I made a little install script for otel:
and I added some output to see if otel finds my installed version of abseil:
Output: Found Abseil: /usr/alpen/lib/cmake/absl
Then in my app I created a little testing lib to see if it will build:
But when compile I always get this error: _reference to ‘baseinternal’ is ambiguous
What is the expected behavior? I can build without interfering header files from different abseil libs.
What is the actual behavior?
I see this error:
Additional context
I looked at the hints here, but they had no effect.