abseil-cpp icon indicating copy to clipboard operation
abseil-cpp copied to clipboard

Missing symbols when using windows shared build

Open h-vetinari opened this issue 3 years ago • 2 comments

I'm trying to compile sentencepiece against a shared build of abseil for conda-forge, and even though it only uses public API, it runs into missing symbols on windows:

word_model.obj : error LNK2001: unresolved external symbol "enum absl::lts_20211102::container_internal::ctrl_t const * const absl::lts_20211102::container_internal::kEmptyGroup" (?kEmptyGroup@container_internal@lts_20211102@absl@@3QBW4ctrl_t@123@B) [D:\bld\sentencepiece-split_1646223867511\work\build\src\sentencepiece.vcxproj]
bpe_model.obj : error LNK2001: unresolved external symbol "enum absl::lts_20211102::container_internal::ctrl_t const * const absl::lts_20211102::container_internal::kEmptyGroup" (?kEmptyGroup@container_internal@lts_20211102@absl@@3QBW4ctrl_t@123@B) [D:\bld\sentencepiece-split_1646223867511\work\build\src\sentencepiece.vcxproj]
char_model.obj : error LNK2001: unresolved external symbol "enum absl::lts_20211102::container_internal::ctrl_t const * const absl::lts_20211102::container_internal::kEmptyGroup" (?kEmptyGroup@container_internal@lts_20211102@absl@@3QBW4ctrl_t@123@B) [D:\bld\sentencepiece-split_1646223867511\work\build\src\sentencepiece.vcxproj]
model_interface.obj : error LNK2001: unresolved external symbol "enum absl::lts_20211102::container_internal::ctrl_t const * const absl::lts_20211102::container_internal::kEmptyGroup" (?kEmptyGroup@container_internal@lts_20211102@absl@@3QBW4ctrl_t@123@B) [D:\bld\sentencepiece-split_1646223867511\work\build\src\sentencepiece.vcxproj]
unigram_model.obj : error LNK2001: unresolved external symbol "enum absl::lts_20211102::container_internal::ctrl_t const * const absl::lts_20211102::container_internal::kEmptyGroup" (?kEmptyGroup@container_internal@lts_20211102@absl@@3QBW4ctrl_t@123@B) [D:\bld\sentencepiece-split_1646223867511\work\build\src\sentencepiece.vcxproj]
model_interface.obj : error LNK2019: unresolved external symbol "private: static void const * const absl::lts_20211102::hash_internal::MixingHashState::kSeed" (?kSeed@MixingHashState@hash_internal@lts_20211102@absl@@0QEBXEB) referenced in function "unsigned __int64 __cdecl absl::lts_20211102::container_internal::DecomposePair<struct absl::lts_20211102::container_internal::raw_hash_set<struct absl::lts_20211102::container_internal::FlatHashMapPolicy<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,unsigned char>,struct absl::lts_20211102::container_internal::StringHash,struct absl::lts_20211102::container_internal::StringEq,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,unsigned char> > >::HashElement,struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,unsigned char> &>(struct absl::lts_20211102::container_internal::raw_hash_set<struct absl::lts_20211102::container_internal::FlatHashMapPolicy<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,unsigned char>,struct absl::lts_20211102::container_internal::StringHash,struct absl::lts_20211102::container_internal::StringEq,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,unsigned char> > >::HashElement &&,struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,unsigned char> &)" (??$DecomposePair@UHashElement@?$raw_hash_set@U?$FlatHashMapPolicy@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@E@container_internal@lts_20211102@absl@@UStringHash@234@UStringEq@234@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@E@std@@@std@@@container_internal@lts_20211102@absl@@AEAU?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@E@std@@@container_internal@lts_20211102@absl@@YA_K$$QEAUHashElement@?$raw_hash_set@U?$FlatHashMapPolicy@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@E@container_internal@lts_20211102@absl@@UStringHash@234@UStringEq@234@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@E@std@@@std@@@012@AEAU?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@E@std@@@Z) [D:\bld\sentencepiece-split_1646223867511\work\build\src\sentencepiece.vcxproj]

I was able to fix the missing kEmptyGroup symbol by moving the initialization to the header and making it constexpr, but for kSeed this is trickier to do, because it's dereferencing an uninitialized pointer to get a (more or less) random value. Even though the accompanying comment says that this seed might only be per-build, I didn't want to kludge this for the conda-forge packaging without aligning with people here.

h-vetinari avatar Mar 05 '22 03:03 h-vetinari

Same symbols missing on a C++11 build against C++11-compiled abseil...

h-vetinari avatar Mar 07 '22 22:03 h-vetinari

Also appears despite setting ABSL_CONSUME_DLL and double-checking that "absl/base/config.h" is #included in the respective headers.

h-vetinari avatar Mar 08 '22 00:03 h-vetinari

Also appears despite setting ABSL_CONSUME_DLL

How did you do this?

isuruf avatar Sep 02 '22 08:09 isuruf

Also appears despite setting ABSL_CONSUME_DLL

How did you do this?

Earlier this year I was trying out a couple of things in a dev-branch on the abseil feedstock (and then trying to build grpc & sentencepiece against that). Once I found out about ABSL_CONSUME_DLL, I tried this in https://github.com/conda-forge/abseil-cpp-feedstock/pull/33.

h-vetinari avatar Sep 02 '22 09:09 h-vetinari

Based on the PR you opened, I guess there were still missing pieces then...

h-vetinari avatar Sep 02 '22 09:09 h-vetinari