Open ivanzz1001 opened 4 days ago
utf8_range::IsStructurallyValid(std::basic_string_view<char, std::char_traits >) is realized in libutf8_validity.a:
# strings libutf8_validity.a | grep IsStructurallyValid
B_ZN10utf8_range19IsStructurallyValidESt17basic_string_viewIcSt11char_traitsIcEE
IsStructurallyValid
_ZN10utf8_range19IsStructurallyValidESt17basic_string_viewIcSt11char_traitsIcEE
_ZN10utf8_range19IsStructurallyValidESt17basic_string_viewIcSt11char_traitsIcEE
I think this might be an issue with how Abseil is configured in your system.
Both protobuf
and utf8_range
use absl::string_view
in their APIs.
Abseil itself has a configuration where you can make absl::string_view
be an alias to std::string_view
.
From the linker error I think the protobuf
library is built with the aliasing on (which is why it is looking for IsStructurallyValid(std::string_view)
), but the utf8_range
library has it off.
You can see the Abseil option here https://abseil.io/docs/cpp/guides/options https://github.com/abseil/abseil-cpp/blob/fa588813c4b2d931737bbe7c4b4f7fa6ed7509db/absl/base/options.h#L127
By default Abseil will autodetect the presence of std::string_view
and alias if it is there.
However, this means that if you try to mix libraries built with different configs (eg one at C++14 and one at C++17) you might get conflicting answers. For those cases, you should manually specify -DABSL_OPTION_USE_STD_STRING_VIEW=0
on all builds to make sure they all agree.
I build brpc(https://github.com/apache/brpc) and meet the following when It link protobuf:
My protobuf version is 'tags/v4.25.0' and I use the following command to build my protobuf:
When I built out the 'libprotobuf.a', I checked my protobuf has already linked 'utf8_validity':
But why It stills report: undefined reference to `utf8_range::IsStructurallyValid(std::basic_string_view<char, std::char_traits >)'
Can anyone help me ?