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

Linking error with prebuilt opentelemetry-cpp and gcc 4.8 #834

Closed
owent opened this issue Jun 8, 2021 · 2 comments · Fixed by #835
Closed

Linking error with prebuilt opentelemetry-cpp and gcc 4.8 #834

owent opened this issue Jun 8, 2021 · 2 comments · Fixed by #835
Labels
bug Something isn't working

Comments

@owent
Copy link
Member

owent commented Jun 8, 2021

Describe your environment
cmake 3.20.0
gcc 4.8
centos 7

Steps to reproduce
Using cmake to build and install opentelemetry-cpp, and then use installed opentelemetry-cpp targets (cmake config) to link.

What is the expected behavior?
Success

What is the actual behavior?

../../third_party/install/linux-x86_64-gnu/lib64/libopentelemetry_trace.a(tracer.cc.o): In function `opentelemetry::v0::nostd::shared_ptr<opentelemetry::v0::trace::Span>& absl::otel_v1::variant_internal::TypedThrowBadVariantAccess<opentelemetry::v0::nostd::shared_ptr<opentelemetry::v0::trace::Span>&>()':
tracer.cc:(.text._ZN4absl7otel_v116variant_internal26TypedThrowBadVariantAccessIRN13opentelemetry2v05nostd10shared_ptrINS4_5trace4SpanEEEEET_v[_ZN4absl7otel_v116variant_internal26TypedThrowBadVariantAccessIRN13opentelemetry2v05nostd10shared_ptrINS4_5trace4SpanEEEEET_v]+0x5): undefined reference to `absl::otel_v1::variant_internal::ThrowBadVariantAccess()'
../../third_party/install/linux-x86_64-gnu/lib64/libopentelemetry_exporter_ostream_span.a(span_exporter.cc.o): In function `absl::otel_v1::variant<bool, int, unsigned int, long, double, std::string, std::vector<bool, std::allocator<bool> >, std::vector<int, std::allocator<int> >, std::vector<unsigned int, std::allocator<unsigned int> >, std::vector<long, std::allocator<long> >, std::vector<double, std::allocator<double> >, std::vector<std::string, std::allocator<std::string> >, unsigned long, std::vector<unsigned long, std::allocator<unsigned long> >, std::vector<unsigned char, std::allocator<unsigned char> > > absl::otel_v1::variant_internal::PerformVisitation<opentelemetry::v0::sdk::common::AttributeConverter&, absl::otel_v1::variant<bool, int, long, unsigned int, double, char const*, opentelemetry::v0::nostd::string_view, opentelemetry::v0::nostd::span<bool const, 18446744073709551615ul>, opentelemetry::v0::nostd::span<int const, 18446744073709551615ul>, opentelemetry::v0::nostd::span<long const, 18446744073709551615ul>, opentelemetry::v0::nostd::span<unsigned int const, 18446744073709551615ul>, opentelemetry::v0::nostd::span<double const, 18446744073709551615ul>, opentelemetry::v0::nostd::span<opentelemetry::v0::nostd::string_view const, 18446744073709551615ul>, unsigned long, opentelemetry::v0::nostd::span<unsigned long const, 18446744073709551615ul>, opentelemetry::v0::nostd::span<unsigned char const, 18446744073709551615ul> > const&>::Run<0ul, 18446744073709551615ul>(std::integral_constant<bool, true>, absl::otel_v1::integer_sequence<unsigned long, 0ul>, std::integral_constant<unsigned long, 18446744073709551615ul>) const':
span_exporter.cc:(.text._ZNK4absl7otel_v116variant_internal17PerformVisitationIRN13opentelemetry2v03sdk6common18AttributeConverterEIRKNS0_7variantIIbiljdPKcNS4_5nostd11string_viewENSC_4spanIKbLm18446744073709551615EEENSE_IKiLm18446744073709551615EEENSE_IKlLm18446744073709551615EEENSE_IKjLm18446744073709551615EEENSE_IKdLm18446744073709551615EEENSE_IKSD_Lm18446744073709551615EEEmNSE_IKmLm18446744073709551615EEENSE_IKhLm18446744073709551615EEEEEEEE3RunIILm0EEILm18446744073709551615EEEENS9_IIbijldSsSt6vectorIbSaIbEES10_IiSaIiEES10_IjSaIjEES10_IlSaIlEES10_IdSaIdEES10_ISsSaISsEEmS10_ImSaImEES10_IhSaIhEEEEESt17integral_constantIbLb1EENS0_16integer_sequenceImIXspT_EEEEDpS1I_ImXT0_EE[_ZNK4absl7otel_v116variant_internal17PerformVisitationIRN13opentelemetry2v03sdk6common18AttributeConverterEIRKNS0_7variantIIbiljdPKcNS4_5nostd11string_viewENSC_4spanIKbLm18446744073709551615EEENSE_IKiLm18446744073709551615EEENSE_IKlLm18446744073709551615EEENSE_IKjLm18446744073709551615EEENSE_IKdLm18446744073709551615EEENSE_IKSD_Lm18446744073709551615EEEmNSE_IKmLm18446744073709551615EEENSE_IKhLm18446744073709551615EEEEEEEE3RunIILm0EEILm18446744073709551615EEEENS9_IIbijldSsSt6vectorIbSaIbEES10_IiSaIiEES10_IjSaIjEES10_IlSaIlEES10_IdSaIdEES10_ISsSaISsEEmS10_ImSaImEES10_IhSaIhEEEEESt17integral_constantIbLb1EENS0_16integer_sequenceImIXspT_EEEEDpS1I_ImXT0_EE]+0x11): undefined reference to `absl::otel_v1::variant_internal::ThrowBadVariantAccess()'
../../third_party/install/linux-x86_64-gnu/lib64/libopentelemetry_exporter_ostream_span.a(span_exporter.cc.o): In function `void absl::otel_v1::variant_internal::PerformVisitation<opentelemetry::v0::exporter::trace::OStreamSpanExporter::OwnedAttributeValueVisitor, absl::otel_v1::variant<bool, int, unsigned int, long, double, std::string, std::vector<bool, std::allocator<bool> >, std::vector<int, std::allocator<int> >, std::vector<unsigned int, std::allocator<unsigned int> >, std::vector<long, std::allocator<long> >, std::vector<double, std::allocator<double> >, std::vector<std::string, std::allocator<std::string> >, unsigned long, std::vector<unsigned long, std::allocator<unsigned long> >, std::vector<unsigned char, std::allocator<unsigned char> > > const&>::Run<0ul, 18446744073709551615ul>(std::integral_constant<bool, true>, absl::otel_v1::integer_sequence<unsigned long, 0ul>, std::integral_constant<unsigned long, 18446744073709551615ul>) const':
span_exporter.cc:(.text._ZNK4absl7otel_v116variant_internal17PerformVisitationIN13opentelemetry2v08exporter5trace19OStreamSpanExporter26OwnedAttributeValueVisitorEIRKNS0_7variantIIbijldSsSt6vectorIbSaIbEESA_IiSaIiEESA_IjSaIjEESA_IlSaIlEESA_IdSaIdEESA_ISsSaISsEEmSA_ImSaImEESA_IhSaIhEEEEEEE3RunIILm0EEILm18446744073709551615EEEEvSt17integral_constantIbLb1EENS0_16integer_sequenceImIXspT_EEEEDpSW_ImXT0_EE[_ZNK4absl7otel_v116variant_internal17PerformVisitationIN13opentelemetry2v08exporter5trace19OStreamSpanExporter26OwnedAttributeValueVisitorEIRKNS0_7variantIIbijldSsSt6vectorIbSaIbEESA_IiSaIiEESA_IjSaIjEESA_IlSaIlEESA_IdSaIdEESA_ISsSaISsEEmSA_ImSaImEESA_IhSaIhEEEEEEE3RunIILm0EEILm18446744073709551615EEEEvSt17integral_constantIbLb1EENS0_16integer_sequenceImIXspT_EEEEDpSW_ImXT0_EE]+0xd): undefined reference to `absl::otel_v1::variant_internal::ThrowBadVariantAccess()'
../../third_party/install/linux-x86_64-gnu/lib64/libopentelemetry_resources.a(resource.cc.o): In function `std::string& absl::otel_v1::variant_internal::TypedThrowBadVariantAccess<std::string&>()':
resource.cc:(.text._ZN4absl7otel_v116variant_internal26TypedThrowBadVariantAccessIRSsEET_v[_ZN4absl7otel_v116variant_internal26TypedThrowBadVariantAccessIRSsEET_v]+0x5): undefined reference to `absl::otel_v1::variant_internal::ThrowBadVariantAccess()'
collect2: error: ld returned 1 exit status
gmake[2]: *** [bin/example_simple] Error 1
gmake[1]: *** [simple/CMakeFiles/example_simple.dir/all] Error 2
gmake: *** [all] Error 2

Additional context

There are two problem.

  1. The code # include "absl/types/variant.h" in api/include/opentelemetry/nostd/variant.h:50 always use local absl/types/variant.h .
  2. ThrowBadVariantAccess in core.cc:29 should be replaced by linking absl::bad_variant_access.
@owent owent added the bug Something isn't working label Jun 8, 2021
owent added a commit to owent/opentelemetry-cpp that referenced this issue Jun 8, 2021
Signed-off-by: owent <admin@owent.net>
@owent owent mentioned this issue Jun 8, 2021
3 tasks
@lalitb
Copy link
Member

lalitb commented Jun 8, 2021

Thanks for reporting @owent. Was absl library installed in the default system path? I am trying to understand what was different as this error was not caught in our CI build. and possibly we need to add tests for this?

@owent
Copy link
Member Author

owent commented Jun 9, 2021

Thanks for reporting @owent. Was absl library installed in the default system path? I am trying to understand what was different as this error was not caught in our CI build. and possibly we need to add tests for this?

I build abseil into my custom path, and then use the abseil to build opentelemetry-cpp.All libraries are installed into installation path.The build script may like below(The real script we use is more complex, because we build all denpendcies within our build system, not only abseil).

WORK_DIR="$PWD";
mkdir -p "$WORK_DIR/build-abseil" && "$WORK_DIR/build-abseil" ;
cmake <PATH of abseil> -DCMAKE_BUILD_TYPE=RelWithDebInfo "-DCMAKE_INSTALL_PREFIX=<installation path>" -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_TESTING=OFF
cmake --build . -j --target install

mkdir -p "$WORK_DIR/opentelemetry-cpp" && "$WORK_DIR/opentelemetry-cpp" ;
cmake <PATH of opentelemetry-cpp> "-DCMAKE_INSTALL_PREFIX=<installation path>" -DCMAKE_FIND_PACKAGE_PREFER_CONFIG=TRUE "-DCMAKE_FIND_ROOT_PATH=<installation path>" "-DCMAKE_PREFIX_PATH=<installation path>" -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON -DWITH_STL=OFF -DWITH_ABSEIL=ON

cmake --build . -j --target install

And the this problem only happen when we have a application outside opentelemetry-cpp and link opentelemetry-cpp::sdk. (Because add_definitions(-DHAVE_ABSEIL) add definition of HAVE_ABSEIL for all sub targets, which will cause variant to use inline implement of ThrowBadVariantAccess)

I think if we add CI matrix for this situation, maybe we could use VCPKG in the runner and install all dependencies with it? And then add CMakeLists.txt files for every example to use opentelemetry-cpp::* from cmake config?

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