which absl version link against to
jowu598 opened this issue · comments
I got:
/usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to absl::Mutex::Unlock()' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to
absl::container_internal::ClearBackingArray(absl::container_internal::CommonFields&, absl::container_internal::PolicyFunctions const&, bool)'
/usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to absl::string_view::find(char, unsigned long) const' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to
absl::Mutex::ReaderLock()'
/usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to absl::hash_internal::MixingHashState::CombineLargeContiguousImpl64(unsigned long, unsigned char const*, unsigned long)' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to
bool absl::str_format_internal::FormatArgImpl::Dispatch<char const*>(absl::str_format_internal::FormatArgImpl::Data, absl::str_format_internal::FormatConversionSpecImpl, void*)'
/usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to absl::container_internal::kEmptyGroup' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to
absl::container_internal::DropDeletesWithoutResize(absl::container_internal::CommonFields&, absl::container_internal::PolicyFunctions const&, void*)'
/usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to absl::hash_internal::MixingHashState::kSeed' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to
bool absl::str_format_internal::FormatArgImpl::Dispatch(absl::str_format_internal::FormatArgImpl::Data, absl::str_format_internal::FormatConversionSpecImpl, void*)'
/usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to absl::Mutex::Lock()' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to
absl::Mutex::~Mutex()'
/usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to bool absl::str_format_internal::FormatArgImpl::Dispatch<long>(absl::str_format_internal::FormatArgImpl::Data, absl::str_format_internal::FormatConversionSpecImpl, void*)' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to
bool absl::str_format_internal::FormatArgImpl::Dispatchabsl::str_format_internal::VoidPtr(absl::str_format_internal::FormatArgImpl::Data, absl::str_format_internal::FormatConversionSpecImpl, void*)'
/usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to bool absl::str_format_internal::FormatArgImpl::Dispatch<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(absl::str_format_internal::FormatArgImpl::Data, absl::str_format_internal::FormatConversionSpecImpl, void*)' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to
bool absl::str_format_internal::FormatArgImpl::Dispatch(absl::str_format_internal::FormatArgImpl::Data, absl::str_format_internal::FormatConversionSpecImpl, void*)'
/usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to absl::base_internal::SpinLockWait(std::atomic<unsigned int>*, int, absl::base_internal::SpinLockWaitTransition const*, absl::base_internal::SchedulingMode)' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to
absl::Mutex::ReaderUnlock()'
/usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to absl::container_internal::EraseMetaOnly(absl::container_internal::CommonFields&, absl::container_internal::ctrl_t*, unsigned long)' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to
absl::str_format_internal::FormatPack[abi:cxx11](absl::str_format_internal::UntypedFormatSpecImpl, absl::Span<absl::str_format_internal::FormatArgImpl const>)'
/usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to absl::hash_internal::MixingHashState::LowLevelHashImpl(unsigned char const*, unsigned long)' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to
absl::ascii_internal::kPropertyBits'
/usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to absl::operator<<(std::ostream&, absl::string_view)' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to
bool absl::str_format_internal::FormatArgImpl::Dispatch(absl::str_format_internal::FormatArgImpl::Data, absl::str_format_internal::FormatConversionSpecImpl, void*)'
/usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to `AbslInternalSpinLockWake'
I got: /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to
absl::Mutex::Unlock()' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to
absl::container_internal::ClearBackingArray(absl::container_internal::CommonFields&, absl::container_internal::PolicyFunctions const&, bool)' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference toabsl::string_view::find(char, unsigned long) const' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to
absl::Mutex::ReaderLock()' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference toabsl::hash_internal::MixingHashState::CombineLargeContiguousImpl64(unsigned long, unsigned char const*, unsigned long)' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to
bool absl::str_format_internal::FormatArgImpl::Dispatch<char const*>(absl::str_format_internal::FormatArgImpl::Data, absl::str_format_internal::FormatConversionSpecImpl, void*)' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference toabsl::container_internal::kEmptyGroup' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to
absl::container_internal::DropDeletesWithoutResize(absl::container_internal::CommonFields&, absl::container_internal::PolicyFunctions const&, void*)' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference toabsl::hash_internal::MixingHashState::kSeed' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to
bool absl::str_format_internal::FormatArgImpl::Dispatch(absl::str_format_internal::FormatArgImpl::Data, absl::str_format_internal::FormatConversionSpecImpl, void*)' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference toabsl::Mutex::Lock()' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to
absl::Mutex::~Mutex()' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference tobool absl::str_format_internal::FormatArgImpl::Dispatch<long>(absl::str_format_internal::FormatArgImpl::Data, absl::str_format_internal::FormatConversionSpecImpl, void*)' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to
bool absl::str_format_internal::FormatArgImpl::Dispatchabsl::str_format_internal::VoidPtr(absl::str_format_internal::FormatArgImpl::Data, absl::str_format_internal::FormatConversionSpecImpl, void*)' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference tobool absl::str_format_internal::FormatArgImpl::Dispatch<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(absl::str_format_internal::FormatArgImpl::Data, absl::str_format_internal::FormatConversionSpecImpl, void*)' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to
bool absl::str_format_internal::FormatArgImpl::Dispatch(absl::str_format_internal::FormatArgImpl::Data, absl::str_format_internal::FormatConversionSpecImpl, void*)' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference toabsl::base_internal::SpinLockWait(std::atomic<unsigned int>*, int, absl::base_internal::SpinLockWaitTransition const*, absl::base_internal::SchedulingMode)' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to
absl::Mutex::ReaderUnlock()' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference toabsl::container_internal::EraseMetaOnly(absl::container_internal::CommonFields&, absl::container_internal::ctrl_t*, unsigned long)' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to
absl::str_format_internal::FormatPack[abi:cxx11](absl::str_format_internal::UntypedFormatSpecImpl, absl::Span<absl::str_format_internal::FormatArgImpl const>)' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference toabsl::hash_internal::MixingHashState::LowLevelHashImpl(unsigned char const*, unsigned long)' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to
absl::ascii_internal::kPropertyBits' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference toabsl::operator<<(std::ostream&, absl::string_view)' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to
bool absl::str_format_internal::FormatArgImpl::Dispatch(absl::str_format_internal::FormatArgImpl::Data, absl::str_format_internal::FormatConversionSpecImpl, void*)' /usr/bin/ld: /usr/local/lib/libre2.so: undefined reference to `AbslInternalSpinLockWake'
The latest re2 link agst to abseil-cpp~20230802.0 after I inspect bazel cache. but the link error is other issues.
Here is my quick solution:
1, build absl from source and export its so: cmake .. -DBUILD_SHARED_LIBS=ON && sudo make install
2, In my example test.cc with re2 API, link absl libs mannually:
g++ test.cc -o test -L/usr/local/lib -lre2 -labsl_base -labsl_synchronization -labsl_raw_hash_set -labsl_str_format_internal
pkg-config re2 --cflags --libs
should suffice to obtain the necessary compiler and linker arguments. (FWIW, our CI uses Ubuntu 22.04 LTS, which installs libabsl-dev
version 0~20210324.2-2
, so problems with the version of Abseil itself should be vanishingly unlikely.)