open-telemetry / open-telemetry/opentelemetry-cpp
Example app example_otlp_http does not link because of missing references to functions in abseil, zlib etc.
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 1.4k
- Forks
- 632
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 75
Description
*Describe your environment
linux, gcc 7.3.1, protobuf 26.1, latest opentelemetry-cpp
Steps to reproduce
mkdir otel-cpp-starter
cd otel-cpp-starter
git clone https://github.com/open-telemetry/opentelemetry-cpp.git
git submodule update --init
cd opentelemetry-cpp
mkdir build
cd build
cmake -DBUILD_TESTING=OFF -DWITH_OTLP_HTTP=ON -DCMAKE_CXX_STANDARD=17 -DBUILD_SHARED_LIBS=OFF -DWITH_ABSEIL=ON -Dabsl_ROOT=/home/abseil/Install -DCURL_LIBRARY=/home/libcurl/lib/libcurl.a -DCURL_INCLUDE_DIR=/home/libcurl/include -DCMAKE_PREFIX_PATH=/home/abseil/Install -DProtobuf_LIBRARIES=/tmp/protobuf/lib64/libprotobuf.a -DProtobuf_INCLUDE_DIR=/tmp/protobuf/include/ -DProtobuf_PROTOC_EXECUTABLE=/tmp/protobuf/bin/protoc ..
(works; no errors)
cmake --build .
[ 6%] Built target opentelemetry_proto
[ 10%] Built target opentelemetry_common
[ 12%] Built target opentelemetry_resources
[ 24%] Built target opentelemetry_trace
[ 41%] Built target opentelemetry_metrics
[ 54%] Built target opentelemetry_logs
[ 56%] Built target opentelemetry_version
[ 58%] Built target opentelemetry_http_client_curl
[ 63%] Built target opentelemetry_otlp_recordable
[ 65%] Built target opentelemetry_exporter_otlp_http_client
[ 68%] Built target opentelemetry_exporter_otlp_http
[ 70%] Built target opentelemetry_exporter_otlp_http_log
[ 73%] Built target opentelemetry_exporter_otlp_http_metric
[ 75%] Built target opentelemetry_exporter_ostream_span
[ 77%] Built target opentelemetry_exporter_ostream_metrics
[ 79%] Built target opentelemetry_exporter_ostream_logs
[ 80%] Built target opentelemetry_exporter_in_memory
[ 81%] Built target common_foo_library
[ 82%] Built target common_logs_foo_library
[ 84%] Built target common_metrics_foo_library
[ 85%] Linking CXX executable example_otlp_http
../../exporters/otlp/libopentelemetry_exporter_otlp_http.a(otlp_http_exporter.cc.o): In function absl::log_internal::LogMessage::operator<<(unsigned long)':
otlp_http_exporter.cc:(.text._ZN4absl12log_internal10LogMessagelsEm[_ZN4absl12log_internal10LogMessagelsEm]+0x1f): undefined reference to absl::log_internal::LogMessage& absl::log_internal::LogMessage::operator<< <unsigned long, 0>(unsigned long const&)'
../../exporters/otlp/libopentelemetry_exporter_otlp_http.a(otlp_http_exporter.cc.o): In function google::protobuf::internal::ArenaAlignAs(unsigned long)':
otlp_http_exporter.cc:(.text._ZN6google8protobuf8internal12ArenaAlignAsEm[_ZN6google8protobuf8internal12ArenaAlignAsEm]+0x74): undefined reference to absl::log_internal::LogMessageFatal::LogMessageFatal(char const*, int, std::basic_string_view<char, std::char_tr
aits >)'
otlp_http_exporter.cc:(.text._ZN6google8protobuf8internal12ArenaAlignAsEm[_ZN6google8protobuf8internal12ArenaAlignAsEm]+0x9e): undefined reference to absl::log_internal::LogMessageFatal::~LogMessageFatal()'
otlp_http_exporter.cc:(.text._ZN6google8protobuf8internal12ArenaAlignAsEm[_ZN6google8protobuf8internal12ArenaAlignAsEm]+0xef): undefined reference to absl::log_internal::LogMessageFatal::LogMessageFatal(char const*, int, std::basic_string_view<char, std::char_tr
aits >)'
(and many other link errors for functions from abseil, zlib etc).
What is the expected behavior?
I expected the opentelemetry-cpp libraries and the executable example_otlp_http to be built correctly.
What is the actual behavior?
The libraries have been built, but there were many link errors for example_otlp_http.
Additional context
I have my own app which I'm trying to build against opentelemetry-cpp in order to send traces to Xray. It now compiles successfully (because I have modfied my first cmake invocation as shown above, and am now building againt protobuf, abseil etc) but I have similar link errors for abseil, zlib etc. My app build doesn't use cmake, but I would like to know how to get example_otlp_http to link in case it gives me any useful insights.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with the provided CMake invocation and cmake --build ., focusing on the example_otlp_http link step and the listed exporter targets. Review the CMake target dependencies involved in that executable; done means example_otlp_http links successfully with the stated static-library configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp, linux
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100