open-telemetry / opentelemetry-cpp-contrib

https://opentelemetry.io/
Apache License 2.0
125 stars 137 forks source link

failed to compile nginx accroding to instrumentation/nginx/README.md #64

Closed zhuizhuhaomeng closed 3 years ago

zhuizhuhaomeng commented 3 years ago

build on Ubuntu 20, got the following error when compile nginx

In file included from /install/include/absl/synchronization/mutex.h:73,
                 from /install/include/grpcpp/impl/codegen/sync.h:32,
                 from /install/include/grpcpp/impl/codegen/client_context.h:55,
                 from /install/include/grpcpp/impl/codegen/call_op_set.h:34,
                 from /install/include/grpcpp/impl/codegen/server_context.h:35,
                 from /install/include/grpcpp/impl/codegen/async_stream.h:26,
                 from /install/include/grpcpp/impl/codegen/async_generic_service.h:26,
                 from /install/include/opentelemetry/proto/collector/trace/v1/trace_service.grpc.pb.h:25,
                 from /install/include/opentelemetry/exporters/otlp/otlp_grpc_exporter.h:10,
                 from /home/ljl/code/opentelemetry-cpp-contrib/instrumentation/nginx/src/otel_ngx_module.cpp:20:
/install/include/absl/synchronization/internal/per_thread_sem.h:84:10: error: reference to ‘base_internal’ is ambiguous
   84 |   friend absl::base_internal::ThreadIdentity* CreateThreadIdentity();
      |          ^~~~
In file included from /install/include/opentelemetry/nostd/absl/utility/utility.h:50,
                 from /install/include/opentelemetry/nostd/absl/types/variant.h:46,
                 from /install/include/opentelemetry/nostd/variant.h:52,
                 from /install/include/opentelemetry/common/attribute_value.h:10,
                 from /install/include/opentelemetry/sdk/trace/recordable.h:6,
                 from /install/include/opentelemetry/sdk/trace/processor.h:8,
                 from /home/ljl/code/opentelemetry-cpp-contrib/instrumentation/nginx/src/otel_ngx_module.cpp:1:
/install/include/opentelemetry/nostd/absl/base/internal/invoke.h:49:11: note: candidates are: ‘namespace absl::otel_v1::base_internal { }’
   49 | namespace base_internal {
      |           ^~~~~~~~~~~~~
In file included from /install/include/absl/synchronization/mutex.h:67,
                 from /install/include/grpcpp/impl/codegen/sync.h:32,
                 from /install/include/grpcpp/impl/codegen/client_context.h:55,
                 from /install/include/grpcpp/impl/codegen/call_op_set.h:34,
                 from /install/include/grpcpp/impl/codegen/server_context.h:35,
                 from /install/include/grpcpp/impl/codegen/async_stream.h:26,
                 from /install/include/grpcpp/impl/codegen/async_generic_service.h:26,
                 from /install/include/opentelemetry/proto/collector/trace/v1/trace_service.grpc.pb.h:25,
                 from /install/include/opentelemetry/exporters/otlp/otlp_grpc_exporter.h:10,
                 from /home/ljl/code/opentelemetry-cpp-contrib/instrumentation/nginx/src/otel_ngx_module.cpp:20:

where the content of the build.make is

184 otel_ngx_module.so: CMakeFiles/otel_ngx_module.dir/src/propagate.cpp.o
185 otel_ngx_module.so: CMakeFiles/otel_ngx_module.dir/src/script.cpp.o
186 otel_ngx_module.so: CMakeFiles/otel_ngx_module.dir/build.make
187 otel_ngx_module.so: opentelemetry-cpp::version-NOTFOUND
188 otel_ngx_module.so: opentelemetry-cpp::common-NOTFOUND
189 otel_ngx_module.so: opentelemetry-cpp::trace-NOTFOUND
190 otel_ngx_module.so: opentelemetry-cpp::otlp_grpc_exporter-NOTFOUND
191 otel_ngx_module.so: opentelemetry-cpp::otlp_http_exporter-NOTFOUND
192 otel_ngx_module.so: opentelemetry-cpp::ostream_span_exporter-NOTFOUND
193 otel_ngx_module.so: opentelemetry-cpp::zpages-NOTFOUND
194 otel_ngx_module.so: opentelemetry-cpp::http_client_curl-NOTFOUND

script for build grpc

#!/bin/bash

mkdir -p cmake/build 
cd cmake/build

cmake -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=/install -DCMAKE_BUILD_TYPE=Release \
  -DgRPC_BUILD_GRPC_NODE_PLUGIN=OFF -DgRPC_BUILD_GRPC_OBJECTIVE_C_PLUGIN=OFF -DgRPC_BUILD_GRPC_PHP_PLUGIN=OFF \
  -DgRPC_BUILD_GRPC_PHP_PLUGIN=OFF -DgRPC_BUILD_GRPC_PYTHON_PLUGIN=OFF -DgRPC_BUILD_GRPC_RUBY_PLUGIN=OFF \
        ../..

make -j2 
sudo make install

script for building opentelemetry-cpp

#!/bin/bash

mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/install \
-DCMAKE_PREFIX_PATH=/install -DWITH_OTLP=ON \
-DWITH_OTLP_HTTP=OFF -DBUILD_TESTING=OFF \
-DWITH_EXAMPLES=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
.. 

make -j6
sudo make install

script for build nginx

#!/bin/bash

mkdir -p build 
cd build 

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/install -DCMAKE_INSTALL_PREFIX=/usr/share/nginx/modules .. 
make -j2
sudo make install
zhuizhuhaomeng commented 3 years ago

this is just a question, but there is no a suitable choice

zhuizhuhaomeng commented 3 years ago

@tobiasstadler cloud you help me with this issue?

tobiasstadler commented 3 years ago

Is this Ubuntu 20.04 or 20.10? What is the output of g++ -v

lalitb commented 3 years ago

@tobiasstadler @zhuizhuhaomeng - Not sure but this could be the conflict between the abseil library from grpc, and one used internally by opentelemetry-cpp for nostd::variant. You may want to read this if it helps:

https://github.com/open-telemetry/opentelemetry-cpp/tree/main/examples/otlp#additional-notes-regarding-abseil-library

zhuizhuhaomeng commented 3 years ago

Ubuntu 20.04.2 LTS

ljl@ljl-VirtualBox:~$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-HskZEa/gcc-9-9.3.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) 

@tobiasstadler

zhuizhuhaomeng commented 3 years ago

@lalitb thanks for your helo that works after add -DWITH_ABSEIL=ON when compiling opentelmetry-cpp