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

Link Error since 3.20 #9975

Closed
thierryba opened this issue May 16, 2022 · 4 comments
Closed

Link Error since 3.20 #9975

thierryba opened this issue May 16, 2022 · 4 comments

Comments

@thierryba
Copy link

What version of protobuf and what language are you using?
Version: 3.20.1
Language: C++

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

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

What did you do?
Steps to reproduce the behavior:

  1. build protobuf
  2. make a simple example with protobuf
  3. link
  4. See error

What did you expect to see
I'm expecting the binary to link flawlessly. It does with any version of protibuf up to (and including) 3.19.4.

What did you see instead?
Undefined symbols for architecture x86_64:
"google::protobuf::internal::InternalMetadata::~InternalMetadata()", referenced from:
google::protobuf::MessageLite::~MessageLite() in libFWProtobuf.a(foo.pb.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

Anything else we should know about your project / environment

@thierryba
Copy link
Author

Now that I dug a bit deeper into protobuf code, the problem is quite simple.
google::protobuf::internal::InternalMetadata::~InternalMetadata() is defined depending on the NDEBUG macro.
So if you build the lib for Release (like I did) and build your app for debug (default), it fails.

@elharo
Copy link
Contributor

elharo commented May 16, 2022

Dupe of #9947 though thanks for filing. I'll see what we can do about this.

@elharo elharo closed this as completed May 16, 2022
@tusharb86
Copy link
Contributor

@elharo It looks like the linked bug #9947 has been closed. I'm hitting the exact same issue as @thierryba on the Android platform with clang (using vcpkg). I've built the Release version of protobuf 3.20.1 and am seeing a linker error with a simple test:

ld: error: undefined symbol: google::protobuf::internal::InternalMetadata::~InternalMetadata()
>>> referenced by message_lite.h:171 (C:/a/_work/1/s/Packages/.../x64-android/include\google/protobuf\message_lite.h:171)
>>>               lto.tmp:(mytestlib::Vec2f::~Vec2f())
>>> referenced by message_lite.h:171 (C:/a/_work/1/s/Packages/.../x64-android/include\google/protobuf\message_lite.h:171)
>>>               lto.tmp:(google::protobuf::MessageLite::~MessageLite())
>>> referenced by message_lite.h:171 (C:/a/_work/1/s/Packages/.../x64-android/include\google/protobuf\message_lite.h:171)
>>>               lto.tmp:(mytestlib::NamedVec2f::~NamedVec2f())
>>> referenced 3 more times
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

Should this bug or #9947 be reopened? It would be great to get this addressed and included in the upcoming 3.21 release. Thanks!

In the meantime, is there a known workaround for the issue?

@tusharb86
Copy link
Contributor

Thinking about it more... this may be due to our team/project's toolchain and a missing definition of NDEBUG. I'll dig deeper to ensure that is setup properly. Sorry for the noise!

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

3 participants