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 when building with new 3.21.1 version #10163

Closed
StavrosMar opened this issue Jun 22, 2022 · 4 comments
Closed

Linking error when building with new 3.21.1 version #10163

StavrosMar opened this issue Jun 22, 2022 · 4 comments
Assignees
Labels

Comments

@StavrosMar
Copy link

StavrosMar commented Jun 22, 2022

What version of protobuf and what language are you using?
Version: main/v3.21.1
Language: C++

What operating system (Linux, Windows, ...) and version?
MacOS 11.4

What runtime / compiler are you using (e.g., python version or gcc version)
Apple clang version 12.0.5 (clang-1205.0.22.11)

What did you do?
Steps to reproduce the behavior:

  1. Donwloaded 3.21.1 all version
  2. Followed the instructions on the README (like I had done before for 3.18.1-rc2)
  3. Regenerated the .cc and .h with the new protoc.
  4. Recompiled project with updated cc files.
  5. There is a linkage issue where it is unable to find the ~InternalMetadata destructor that has been moved out to a separate message_lite.cc file in 3.21.1 vs in 3.18.1-rc2 it was defined fully inside the .h class file. Please note this is the only error.
  6. Repeated the same procedure for the proto example on the google website i.e. addresbook and I get exactly the same error.
  7. Reverted back to 3.18.1-rc2 everything compiles fine without issues.

What did you expect to see
No Linkage issue should happen

What did you see instead?
Linkage issue when building the C++ project with CMake.

@StavrosMar StavrosMar changed the title Linker error Linking error when building with new 3.21.1 version Jun 22, 2022
@shaod2 shaod2 added the c++ label Jun 22, 2022
@acozzette
Copy link
Member

@StavrosMar I think the likely problem is that you rebuilt your generated code with the new protoc but did not upgrade libprotobuf (or libprotobuf-lite). For C++ the protoc version must exactly match the libprotobuf version as we don't support mixing different versions this way.

@StavrosMar
Copy link
Author

@acozzette when running nm on the libprotobuff under /usr/local/lib I can see that the InternalMetadata objects are in there. The CMake is using the library under /usr/local/lib, I am thinking to just move the code manually inside the message_lite.h and problem should be solved, what do you think ?

@acozzette
Copy link
Member

Actually from looking more closely I believe this has to do with mixing optimized and unoptimized code. The decision of whether to put this destructor in the header or .cc file is determined by the NDEBUG macro, so it's important for NDEBUG to be defined (or undefined) consistently across libprotobuf and the application code. There is more information about this in #9947.

@StavrosMar
Copy link
Author

Thank you , I will set it on my cmake and see if it works , I will close the issue

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

No branches or pull requests

3 participants