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

/usr/local/include/absl/base/internal/identity.h:26:8: error: redefinition of 'identity' #848

Closed
anoyli opened this issue Jun 11, 2021 · 6 comments

Comments

@anoyli
Copy link

anoyli commented Jun 11, 2021

Hi Team, an error occur during my make procedure of opentelemetry-cpp in branch: v1.0.0-rc1.
Here is the full stack trace

In file included from ~/Code/otel/opentelemetry-cpp/examples/grpc/client.cpp:1:
In file included from ~/Code/otel/opentelemetry-cpp/examples/grpc/tracer_common.h:15:
In file included from /usr/local/include/grpcpp/grpcpp.h:53:
In file included from /usr/local/include/grpcpp/channel.h:28:
In file included from /usr/local/include/grpcpp/impl/codegen/completion_queue.h:43:
In file included from /usr/local/include/grpcpp/impl/codegen/sync.h:35:
In file included from /usr/local/include/absl/synchronization/mutex.h:66:
/usr/local/include/absl/base/internal/identity.h:26:8: error: redefinition of 'identity'
struct identity {
       ^
~/Code/otel/opentelemetry-cpp/api/include/opentelemetry/nostd/./absl/types/../types/internal/../../base/internal/identity.h:26:8: note: previous definition is here
struct identity {
       ^
In file included from ~/Code/otel/opentelemetry-cpp/examples/grpc/client.cpp:1:
In file included from ~/Code/otel/opentelemetry-cpp/examples/grpc/tracer_common.h:5:
In file included from ~/Code/otel/opentelemetry-cpp/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h:6:
In file included from ~/Code/otel/opentelemetry-cpp/api/include/opentelemetry/nostd/type_traits.h:9:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/array:112:

is there anything i am missing?

@lalitb
Copy link
Member

lalitb commented Jun 11, 2021

Thanks for reporting the issue. Could you please add the build steps used which caused the error?

@maxgolov
Copy link
Contributor

maxgolov commented Jun 11, 2021

Can you confirm the Xcode / exact clang compiler version? Could you also please pull this PR, which may fix the issue for you:

#840 - reorder the include headers in client.cpp

Here:

#include <grpcpp/grpcpp.h>

This fix was submitted after v1.0.0-rc1 and was necessary for an older vs2015 compiler. But it was unnecessary for recent clang, where everything should work well... maybe you are using relatively old Xcode / clang compiler?

@anoyli
Copy link
Author

anoyli commented Jun 12, 2021

Can you confirm the Xcode / exact clang compiler version? Could you also please pull this PR, which may fix the issue for you:

#840 - reorder the include headers in client.cpp

Here:

#include <grpcpp/grpcpp.h>

This fix was submitted after v1.0.0-rc1 and was necessary for an older vs2015 compiler. But it was unnecessary for recent clang, where everything should work well... maybe you are using relatively old Xcode / clang compiler?

Hi @maxgolov , thanks for your reply. my clang version is as follow:

$ clang --version
Apple clang version 11.0.0 (clang-1100.0.33.17)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

@anoyli
Copy link
Author

anoyli commented Jun 12, 2021

Thanks for reporting the issue. Could you please add the build steps used which caused the error?

Hi @lalitb , i just follow the guide:
https://github.com/open-telemetry/opentelemetry-cpp/blob/main/INSTALL.md#building-as-standalone-cmake-project

my command as follow:

$ git clone --recursive -b v1.0.0-rc1 https://github.com/open-telemetry/opentelemetry-cpp
……

$ cd opentelemetry-cpp
$ mkdir build && cd build
$ cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DWITH_OTLP=ON -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -DOPENSSL_LIBRARIES=/usr/local/opt/openssl/lib -DOPENSSL_SSL_LIBRARY=/usr/local/opt/[email protected]/lib/libssl.dylib -DOPENSSL_CRYPTO_LIBRARY=/usr/local/opt/[email protected]/lib/libcrypto.dylib ..
……

$ cmake --build . --target all

and the error occur during the command: cmake --build . --target all

@maxgolov
Copy link
Contributor

maxgolov commented Jun 12, 2021

@anoyli - I have reproduced your issue with v1.0.0-rc1 and clang-11.0.3. Then I pulled the latest. And I can confirm that the fix I mentioned above resolves it: #840 - reorder the include headers in client.cpp. Unfortunately we require gRPC generated headers to be included first before the rest of OpenTelemetry API due to issue in clang-11 and other older compilers, like Visual Studio 2015.. as long as you position gRPC stubs before the rest of OpenTelemetry API, everything should work well.

Please pick up the latest code example using git pull origin main and recompile. @lalitb will be releasing new label in a week with this updated example. I think upgrading your build system to latest-latest Xcode 12.5 would have also solved it. But the fasted would be just git pull origin main 😄

Got it compiling successfully:

maxgolov@maxgolov-MBP grpc % ls -l
total 15608
drwxr-xr-x  7 maxgolov  staff      224 Jun 11 20:59 CMakeFiles
-rw-r--r--  1 maxgolov  staff      374 Jun 11 20:52 CTestTestfile.cmake
-rw-r--r--  1 maxgolov  staff    14568 Jun 11 20:52 Makefile
-rwxr-xr-x  1 maxgolov  staff  3510548 Jun 11 21:01 client
-rw-r--r--  1 maxgolov  staff     1166 Jun 11 20:52 cmake_install.cmake
-rw-r--r--  1 maxgolov  staff   875800 Jun 11 21:01 libexample_grpc_proto.a
-rw-r--r--  1 maxgolov  staff     4487 Jun 11 20:58 messages.grpc.pb.cc
-rw-r--r--  1 maxgolov  staff    15558 Jun 11 20:58 messages.grpc.pb.h
-rw-r--r--  1 maxgolov  staff    20242 Jun 11 20:58 messages.pb.cc
-rw-r--r--  1 maxgolov  staff    17756 Jun 11 20:58 messages.pb.h
-rwxr-xr-x  1 maxgolov  staff  3509456 Jun 11 21:01 server

With this fix:

maxgolov@maxgolov-MBP grpc % clang -v
Apple clang version 11.0.3 (clang-1103.0.32.62)
Target: x86_64-apple-darwin20.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
maxgolov@maxgolov-MBP grpc % git log ~/build/opentelemetry-cpp.v1/examples/grpc/
commit 5acf4cf59776197f13482b0009f29a9bf113c886
Author: Max Golovanov <[email protected]>
Date:   Wed Jun 9 00:21:25 2021 -0700

    More fixes to build all with Visual Studio 2015 (#840)

I'm closing it as Fixed by #840

@anoyli
Copy link
Author

anoyli commented Jun 12, 2021

@anoyli - I have reproduced your issue with v1.0.0-rc1 and clang-11.0.3. Then I pulled the latest. And I can confirm that the fix I mentioned above resolves it: #840 - reorder the include headers in client.cpp. Unfortunately we require gRPC generated headers to be included first before the rest of OpenTelemetry API due to issue in clang-11 and other older compilers, like Visual Studio 2015.. as long as you position gRPC stubs before the rest of OpenTelemetry API, everything should work well.

Please pick up the latest code example using git pull origin main and recompile. @lalitb will be releasing new label in a week with this updated example. I think upgrading your build system to latest-latest Xcode 12.5 would have also solved it. But the fasted would be just git pull origin main 😄

Got it compiling successfully:

maxgolov@maxgolov-MBP grpc % ls -l
total 15608
drwxr-xr-x  7 maxgolov  staff      224 Jun 11 20:59 CMakeFiles
-rw-r--r--  1 maxgolov  staff      374 Jun 11 20:52 CTestTestfile.cmake
-rw-r--r--  1 maxgolov  staff    14568 Jun 11 20:52 Makefile
-rwxr-xr-x  1 maxgolov  staff  3510548 Jun 11 21:01 client
-rw-r--r--  1 maxgolov  staff     1166 Jun 11 20:52 cmake_install.cmake
-rw-r--r--  1 maxgolov  staff   875800 Jun 11 21:01 libexample_grpc_proto.a
-rw-r--r--  1 maxgolov  staff     4487 Jun 11 20:58 messages.grpc.pb.cc
-rw-r--r--  1 maxgolov  staff    15558 Jun 11 20:58 messages.grpc.pb.h
-rw-r--r--  1 maxgolov  staff    20242 Jun 11 20:58 messages.pb.cc
-rw-r--r--  1 maxgolov  staff    17756 Jun 11 20:58 messages.pb.h
-rwxr-xr-x  1 maxgolov  staff  3509456 Jun 11 21:01 server

With this fix:

maxgolov@maxgolov-MBP grpc % clang -v
Apple clang version 11.0.3 (clang-1103.0.32.62)
Target: x86_64-apple-darwin20.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
maxgolov@maxgolov-MBP grpc % git log ~/build/opentelemetry-cpp.v1/examples/grpc/
commit 5acf4cf59776197f13482b0009f29a9bf113c886
Author: Max Golovanov <[email protected]>
Date:   Wed Jun 9 00:21:25 2021 -0700

    More fixes to build all with Visual Studio 2015 (#840)

I'm closing it as Fixed by #840

oh, thank you very muh! @maxgolov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants