c++ 无法构建Opentelemetry Cpp:对`absl::lts_20220623::variant_internal的未定义引用

x33g5p2x  于 2023-07-01  发布在  其他
关注(0)|答案(1)|浏览(276)

我可以使用他们提供的https://github.com/open-telemetry/opentelemetry-cpp/的cmake文件进行构建,但是当我尝试使用g++ -o test test.cc -lopentelemetry_trace -lopentelemetry_exporter_otlp_grpc -lopentelemetry_resources -lopentelemetry_common时,我得到了这样的错误:

[root@OS otlp]# g++ -o test test.cc  -lopentelemetry_trace -lopentelemetry_exporter_otlp_grpc -lopentelemetry_resources -lopentelemetry_common
/usr/bin/ld: /usr/local/lib64/libopentelemetry_trace.a(tracer.cc.o): in function `opentelemetry::v1::nostd::shared_ptr<opentelemetry::v1::trace::Span>& absl::lts_20220623::variant_internal::TypedThrowBadVariantAccess<opentelemetry::v1::nostd::shared_ptr<opentelemetry::v1::trace::Span>&>()':
tracer.cc:(.text._ZN4absl12lts_2022062316variant_internal26TypedThrowBadVariantAccessIRN13opentelemetry2v15nostd10shared_ptrINS4_5trace4SpanEEEEET_v[_ZN4absl12lts_2022062316variant_internal26TypedThrowBadVariantAccessIRN13opentelemetry2v15nostd10shared_ptrINS4_5trace4SpanEEEEET_v]+0x5): undefined reference to `absl::lts_20220623::variant_internal::ThrowBadVariantAccess()'
/usr/bin/ld: /usr/local/lib64/libopentelemetry_trace.a(tracer.cc.o): in function `opentelemetry::v1::trace::SpanContext const& absl::lts_20220623::variant_internal::TypedThrowBadVariantAccess<opentelemetry::v1::trace::SpanContext const&>()':
tracer.cc:(.text._ZN4absl12lts_2022062316variant_internal26TypedThrowBadVariantAccessIRKN13opentelemetry2v15trace11SpanContextEEET_v[_ZN4absl12lts_2022062316variant_internal26TypedThrowBadVariantAccessIRKN13opentelemetry2v15trace11SpanContextEEET_v]+0x5): undefined reference to `absl::lts_20220623::variant_internal::ThrowBadVariantAccess()'
/usr/bin/ld: /usr/local/lib64/libopentelemetry_trace.a(tracer.cc.o): in function `opentelemetry::v1::context::Context const& absl::lts_20220623::variant_internal::TypedThrowBadVariantAccess<opentelemetry::v1::context::Context const&>()':
tracer.cc:(.text._ZN4absl12lts_2022062316variant_internal26TypedThrowBadVariantAccessIRKN13opentelemetry2v17context7ContextEEET_v[_ZN4absl12lts_2022062316variant_internal26TypedThrowBadVariantAccessIRKN13opentelemetry2v17context7ContextEEET_v]+0x5): undefined reference to `absl::lts_20220623::variant_internal::ThrowBadVariantAccess()'
/usr/bin/ld: /usr/local/lib64/libopentelemetry_exporter_otlp_g

输出似乎告诉我absl::lts_20220623::variant_internal不存在于libopentelemetry_trace.a文件中,但我已经通过构建他们的项目安装了abseil,我如何使用g++提供abseil lib?
非常感谢!

rdlzhqv9

rdlzhqv91#

下列文件丢失

lib file: abseil_dll.lib
dll file :abseil_dll.dll

我使用vcpkg。
安装Opentelemetry-cpp

# vcpkg_root\installed\x64-windows\lib     
link_directories(${VCPKG_LIBRARY})    
add_executable(example "example.cc")
# abseil_dll is abseil_dll.lib
target_link_libraries(example abseil_dll opentelemetry_common opentelemetry_resources opentelemetry_trace opentelemetry_exporter_ostream_span opentelemetry_version)
#vcpkg_root\installed\x64-windows\bin. this have abseil_dll.dll
set_target_properties(example PROPERTIES RUNTIME_OUTPUT_DIRECTORY  ${VCPKG_BIN})

相关问题