open-telemetry / opentelemetry-cpp

The OpenTelemetry C++ Client
https://opentelemetry.io/
Apache License 2.0
841 stars 404 forks source link

Getting Compilation error: absl::bad_variant_access #3065

Open krishna-ezlo opened 1 day ago

krishna-ezlo commented 1 day ago

Please help me resolve the issue!

I'm using ubuntu and followed the tutorials from https://opentelemetry.io/docs/languages/cpp/getting-started and, https://opentelemetry.io/docs/languages/cpp/exporters/

Additionally:

  1. Installed abseil-cpp from github
  2. Installed protobuf from ubuntu-software
  3. Installed gRPC from github

the command i've used to compile opentelemetry-cpp is:

cmake -DBUILD_TESTING:BOOL=OFF     -DBUILD_SHARED_LIBS:BOOL=ON     -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON     -DWITH_JAEGER:BOOL=OFF     -DWITH_OTLP_HTTP:BOOL=OFF     -DWITH_OTLP_GRPC:BOOL=OFF     -DWITH_PROMETHEUS:BOOL=OFF     -DWITH_ZIPKIN:BOOL=OFF     -DWITH_EXAMPLES:BOOL=OFF     -DOTELCPP_VERSIONED_LIBS:BOOL=ON     -DBUILD_PACKAGE=ON     -DWITH_ABSEIL=ON     -DWITH_STL=ON     -DCMAKE_PREFIX_PATH=/usr/alpen     ..

Here is what I'm getting in console:

Terminal Command:

.../otel-cpp-starter/roll-dice/build$ cmake ..

Terminal Response:

-- The C compiler identification is GNU 13.2.0
-- The CXX compiler identification is GNU 13.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Found opentelemetry-cpp: /media/nds/projects/nds/ezlo/opentelemetry/otel-cpp-starter/otel-cpp/include  
-- Configuring done (0.3s)

CMake Error at /media/nds/projects/nds/ezlo/opentelemetry/otel-cpp-starter/otel-cpp/lib/cmake/opentelemetry-cpp/opentelemetry-cpp-target.cmake:61 (set_target_properties):
  The link interface of target "opentelemetry-cpp::api" contains:

    absl::bad_variant_access

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

Call Stack (most recent call first):
  /media/nds/projects/nds/ezlo/opentelemetry/otel-cpp-starter/otel-cpp/lib/cmake/opentelemetry-cpp/opentelemetry-cpp-config.cmake:92 (include)
  CMakeLists.txt:24 (find_package)

CMake Error at /media/nds/projects/nds/ezlo/opentelemetry/otel-cpp-starter/otel-cpp/lib/cmake/opentelemetry-cpp/opentelemetry-cpp-target.cmake:77 (set_target_properties):
  The link interface of target "opentelemetry-cpp::common" contains:

    absl::strings

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

Call Stack (most recent call first):
  /media/nds/projects/nds/ezlo/opentelemetry/otel-cpp-starter/otel-cpp/lib/cmake/opentelemetry-cpp/opentelemetry-cpp-config.cmake:92 (include)
  CMakeLists.txt:24 (find_package)

-- Generating done (0.0s)
CMake Generate step failed.  Build files cannot be regenerated correctly.
owent commented 1 day ago

Please add find_package(absl CONFIG) into cmake script file of your project. We should have documents about this problem.

krishna-ezlo commented 4 hours ago

Please add find_package(absl CONFIG) into cmake script file of your project. We should have documents about this problem.

This solution did solved the above mentioned issue, but now I've encountered another error, although it is available at "../../otel-cpp/lib":

./dice-server: error while loading shared libraries: libopentelemetry_otlp_recordable.so.1: cannot open shared object file: No such file or directory
owent commented 1 hour ago

cts/nds/ezlo/opentelemetry/otel-cp

Please add find_package(absl CONFIG) into cmake script file of your project. We should have documents about this problem.

This solution did solved the above mentioned issue, but now I've encountered another error, although it is available at "../../otel-cpp/lib":

./dice-server: error while loading shared libraries: libopentelemetry_otlp_recordable.so.1: cannot open shared object file: No such file or directory

Do you install otel-cpp? cmake --build <BUILD DIR> -j && cmake --install <BUILD DIR> --prefix <INSTALL PREFIX> can be used to install all components.

<INSTALL PREFIX> may be /usr/alpen according to the command used to compile opentelemetry-cpp.