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

[INLONG-380] Cpp client link error when gcc optimization is disabled #975

Closed
dockerzhang opened this issue Jul 28, 2021 · 0 comments
Closed

Comments

@dockerzhang
Copy link
Contributor

We encountered tube cpp client link error when we migrate build tools from CMake to Bazel.

The error message is as below:

client_connection.cc: (.text+0xff0): undefined reference to `tubemq::ClientConnection::kConnnectMaxTimeMs'

client_service.cc:
(.text._ZN6tubemq14ConnectionPoolC2ERSt10shared_ptrINS_12ExecutorPoolEE[_ZN6tubemq14ConnectionPoolC5ERSt10shared_ptrINS_12ExecutorPoolEE]+0xbe): undefined reference to `tubemq::ConnectionPool::kRegularTimerSecond'

This link error can be reproduced in CMake environment when you remove "-O2" in CMAKE_CXX_FLAGS

According to cpp standard(https://en.cppreference.com/w/cpp/language/static), 

"If a const non-inline (since C+17) static data member or a constexpr static data member (since C11)(until C17) is odr-used, a definition at namespace scope is still required, but it cannot have an initializer. A definition may be provided even though redundant (since C+17)."

 

Possible fix:

  1. Add static const variable definition in src/client_connection.cc and src/client_service.cc
  2. Or change static const variable to enum

 

Further consideration:

Turn off compiler optimization in CI to make sure the compiler optimization will not shadow the compile error or link error

JIRA link - [INLONG-380] created by sheepke
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant