-
Notifications
You must be signed in to change notification settings - Fork 15.6k
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
missing abseil symbols when linking libprotobuf to application #19494
Comments
i've resorted to using version 21.12 (which does not have any abseil dependence) as i didn't like the hacks that've been suggested as the fix. |
Same here. I can't believe how many variations of this problem have been reported and how many of the "fixes" I've tried that didn't work. |
be stucked on v21.12 |
Adding this line to your CMakeLists.txt file should fix it: |
Yes, that does fix all of my problem, thank you! |
Well, I still have the same problem trying to build my project for arm64-android. I have practically the same working environment. |
@Nullarity Did you compile protobuf+abseil from source, or are you trying to use packages provided for arm64-android? |
@gmabey I tried to use vcpkg; no luck. Right now, I'm trying to build abseil for Android, and this is quite a quest too. In the documentation, they say c++ 14, but when I try to build it, it fails on some 'consteval' expressions, which are c++ 20 features. Messy stuff. |
What version of protobuf and what language are you using?
Version: 3.29.0
Language: C++
What operating system (Linux, Windows, ...) and version?
Linux Ubuntu 22.04
What runtime / compiler are you using (e.g., python version or gcc version)
gcc 11.4.0
cmake 3.22.1
What did you do?
I built protobuf from source:
which goes smoothly. However, when following the instructions on how to link an application to it, there are unresolved symbols.
What did you expect to see
Composing the very simplest of main.cpp files and using this CMakeLists.txt should successfully link -- according to the documentation that I've read at https://github.com/protocolbuffers/protobuf/blob/main/cmake/README.md
CMakeLists.txt
What did you see instead?
Tons of unresolved symbol errors:
errs.txt
Anything else we should know about your project / environment
I think this is related to #19375 and #18933 but I created this issue because I wanted to establish this poor behavior on yet another version/OS combination.
There is a solution to this on StackOverflow: https://stackoverflow.com/questions/75667971/how-do-i-properly-link-the-google-protocol-buffers-library-with-my-application-a
I suspected it was something like that, but I thought that it was unthinkable that the protobuf authors would leave such a ragged edge on their otherwise smooth and silky interfaces.
However, it may be that the cmake build instructions have been neglected recently, like ever since abseil was introduced as a dependency (man_shrug).
I expected (and looked for, but did not find) a cmake variable that could be inserted into my
target_link_libraries()
line that would include all needed libraries in order for my application to link properly, and that's what I would recommend be done to improve this situation.That is, if the
cmake
variableprotobuf::libprotobuf
simply included those 3 abseil libraries instead of justlibprotobuf.a
then it would be easily maintainable for application writers if more abseil libs were to become required.Other thoughts:
If this really has been an issue since abseil was introduced as a dependency, then I have to wonder what isn't getting coverage in the release process for it to have gone untreated for this long.
I suspect that the bazel builds get the bulk of the attention from developers, but I naively suspect that there are more cmake users than bazel users out there.
The text was updated successfully, but these errors were encountered: