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

undefined reference errors (absl::strings_internal::CatPieces and absl::ByChar::Find) #640

Closed
lanctot opened this issue Mar 13, 2020 · 13 comments
Assignees

Comments

@lanctot
Copy link

lanctot commented Mar 13, 2020

Hi all,

Thanks for the great project! We are using it in OpenSpiel and this week, we encountered a few undefined reference errors (building via CMake both using clang++ and g++) cause by a commit between today and Monday March 8th, so we've had to fix our dependency to a March 6th commit.

Maybe we have to link to a new target, or we're using StrCat in a way that is no longer supported?

Here's the full error if it helps:

[ 43%] Building CXX object games/CMakeFiles/bridge_double_dummy_solver.dir/bridge/double_dummy_solver/src/File.cpp.o
/usr/bin/ld: ../CMakeFiles/open_spiel_core.dir/spiel.cc.o: in function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > absl::StrCat<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, char [7], std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(absl::AlphaNum const&, absl::AlphaNum const&, absl::AlphaNum const&, absl::AlphaNum const&, absl::AlphaNum const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const (&) [7], std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
spiel.cc:(.text._ZN4absl6StrCatIJNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEA7_cS6_EEES6_RKNS_8AlphaNumESA_SA_SA_SA_DpRKT_[_ZN4absl6StrCatIJNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEA7_cS6_EEES6_RKNS_8AlphaNumESA_SA_SA_SA_DpRKT_]+0x151): undefined reference to `absl::strings_internal::CatPieces[abi:cxx11](std::initializer_list<std::basic_string_view<char, std::char_traits<char> > >)'
/usr/bin/ld: ../CMakeFiles/open_spiel_core.dir/spiel.cc.o: in function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > absl::StrCat<char [2]>(absl::AlphaNum const&, absl::AlphaNum const&, absl::AlphaNum const&, absl::AlphaNum const&, absl::AlphaNum const&, char const (&) [2])':
spiel.cc:(.text._ZN4absl6StrCatIJA2_cEEENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKNS_8AlphaNumESA_SA_SA_SA_DpRKT_[_ZN4absl6StrCatIJA2_cEEENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKNS_8AlphaNumESA_SA_SA_SA_DpRKT_]+0xe3): undefined reference to `absl::strings_internal::CatPieces[abi:cxx11](std::initializer_list<std::basic_string_view<char, std::char_traits<char> > >)'
/usr/bin/ld: ../CMakeFiles/open_spiel_core.dir/spiel.cc.o: in function `absl::strings_internal::SplitIterator<absl::strings_internal::Splitter<absl::ByChar, absl::AllowEmpty> >::operator++()':
spiel.cc:(.text._ZN4absl16strings_internal13SplitIteratorINS0_8SplitterINS_6ByCharENS_10AllowEmptyEEEEppEv[_ZN4absl16strings_internal13SplitIteratorINS0_8SplitterINS_6ByCharENS_10AllowEmptyEEEEppEv]+0x79): undefined reference to `absl::ByChar::Find(std::basic_string_view<char, std::char_traits<char> >, unsigned long) const'
[ 44%] Building CXX object games/CMakeFiles/games.dir/blotto.cc.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [examples/CMakeFiles/matrix_example.dir/build.make:153: examples/matrix_example] Error 1
make[1]: *** [CMakeFiles/Makefile2:5181: examples/CMakeFiles/matrix_example.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

The file it is failing on is spiel.cc (edit: also blotto.cc) which use StrCat, StrJoin, and StrAppend.

@derekmauro
Copy link
Member

Thanks for the report. I think I've found the problem. I think the setting of ABSL_CXX_STANDARD was accidentally removed in the last commit. Look out for a fix on Monday.

@derekmauro derekmauro self-assigned this Mar 14, 2020
@lanctot
Copy link
Author

lanctot commented Mar 14, 2020

Thanks for the quick response!

Confirmed on my end: if I add back what was removed from AbseilConfigureCopts.make in commit c695489 then it works.

@lanctot
Copy link
Author

lanctot commented Mar 15, 2020

Hi @derekmauro ,

Can you think of any reasons that similar errors would occur when building Tensorflow via bazel? (See google-deepmind/open_spiel#172 if you're curious.)

I know this one is on our end but it's a bit of a mystery to us, so thought you might have an idea or could point us in the right direction.

@derekmauro
Copy link
Member

Sure, I responded on that issue.

rongjiecomputer pushed a commit to rongjiecomputer/abseil-cpp that referenced this issue Oct 8, 2020
--
91ca367a7548270155721bdda74611aeea2a2153 by Abseil Team <absl-team@google.com>:

Replace the only usage of btree_node::swap with simpler logic using transfers and delete btree_node::swap.

Add a benchmark for constructing small containers.

PiperOrigin-RevId: 301169874

--
ff9d73a7125b7f8ab5733cda877204dfbfac138e by Derek Mauro <dmauro@google.com>:

Ensure ABSL_CXX_STANDARD is set.
Fixes abseil#640

PiperOrigin-RevId: 301160106

--
14ca0beee8c109e532134e7e9da7b072da1bf911 by Abseil Team <absl-team@google.com>:

Rollback the change to make Cord iterators a fixed size.  That change increased the iterator size, which can cause a deep recursion call to hit the stack memory limit, in turn causing a signal 11 failure.

PiperOrigin-RevId: 301084915

--
619e3cd9e56408bdb8b3b5a1e08dda1e95242264 by Matthew Brown <matthewbr@google.com>:

Internal Change

PiperOrigin-RevId: 300832828

--
64f8d62ab4c4c78077dbe85a9595a8eeb6d16608 by Gennadiy Rozental <rogeeff@google.com>:

Fix for empty braces support.

We will call proper aggregate construction in case when {} is used as default value. In other words instead of "new T", we'll call "new T{}".

PiperOrigin-RevId: 300715686

--
db3f65594d6db8b104b01262f884dff465b696ef by Abseil Team <absl-team@google.com>:

Emscripten supports thread-local storage nowadays.

PiperOrigin-RevId: 300675185
GitOrigin-RevId: 91ca367a7548270155721bdda74611aeea2a2153
Change-Id: I3344f745f9c3fc78775532b1808442fabd98e34a
@iDonghq
Copy link

iDonghq commented Jun 16, 2022

[ 56%] Linking CXX executable cartographer_print_configuration
CMakeFiles/cartographer_print_configuration.dir/cartographer/common/print_configuration_main.cc.o: In function cartographer::common::PrintSubdictionaryById(cartographer::common::LuaParameterDictionary*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)': print_configuration_main.cc:(.text+0x244): undefined reference to absl::ByChar::Find(std::basic_string_view<char, std::char_traits >, unsigned long) const'
print_configuration_main.cc:(.text+0x65c): undefined reference to absl::ByChar::Find(std::basic_string_view<char, std::char_traits<char> >, unsigned long) const' CMakeFiles/cartographer_print_configuration.dir/cartographer/common/print_configuration_main.cc.o: In function absl::strings_internal::Splitter<absl::ByChar, absl::SkipEmpty, std::basic_string_view<char, std::char_traits > >::ConvertToContainer<std::vector<std::basic_string_view<char, std::char_traits >, std::allocator<std::basic_string_view<char, std::char_traits > > >, std::basic_string_view<char, std::char_traits >, false>::operator()(absl::strings_internal::Splitter<absl::ByChar, absl::SkipEmpty, std::basic_string_view<char, std::char_traits > > const&) const':
print_configuration_main.cc:(.text.ZNK4absl16strings_internal8SplitterINS_6ByCharENS_9SkipEmptyESt17basic_string_viewIcSt11char_traitsIcEEE18ConvertToContainerISt6vectorIS7_SaIS7_EES7_Lb0EEclERKS8[ZNK4absl16strings_internal8SplitterINS_6ByCharENS_9SkipEmptyESt17basic_string_viewIcSt11char_traitsIcEEE18ConvertToContainerISt6vectorIS7_SaIS7_EES7_Lb0EEclERKS8]+0xc8): undefined reference to absl::ByChar::Find(std::basic_string_view<char, std::char_traits<char> >, unsigned long) const' print_configuration_main.cc:(.text._ZNK4absl16strings_internal8SplitterINS_6ByCharENS_9SkipEmptyESt17basic_string_viewIcSt11char_traitsIcEEE18ConvertToContainerISt6vectorIS7_SaIS7_EES7_Lb0EEclERKS8_[_ZNK4absl16strings_internal8SplitterINS_6ByCharENS_9SkipEmptyESt17basic_string_viewIcSt11char_traitsIcEEE18ConvertToContainerISt6vectorIS7_SaIS7_EES7_Lb0EEclERKS8_]+0x194): undefined reference to absl::ByChar::Find(std::basic_string_view<char, std::char_traits >, unsigned long) const'
collect2: error: ld returned 1 exit status
CMakeFiles/cartographer_print_configuration.dir/build.make:153: recipe for target 'cartographer_print_configuration' failed
make[2]: *** [cartographer_print_configuration] Error 1
CMakeFiles/Makefile2:421: recipe for target 'CMakeFiles/cartographer_print_configuration.dir/all' failed
make[1]: *** [CMakeFiles/cartographer_print_configuration.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
libcartographer.a(histogram.cc.o): In function cartographer::common::Histogram::ToString[abi:cxx11](int) const': histogram.cc:(.text+0x310): undefined reference to absl::strings_internal::CatPieces[abi:cxx11](std::initializer_list<std::basic_string_view<char, std::char_traits > >)'
histogram.cc:(.text+0x778): undefined reference to `absl::strings_internal::AppendPieces(std::__cxx11::basic_string<char, std::char_traits, std::allocator >*, std::initializer_list<std::basic_string_view<char, std::char_traits > >)'
collect2: error: ld returned 1 exit status
CMakeFiles/cartographer_pbstream.dir/build.make:153: recipe for target 'cartographer_pbstream' failed
make[2]: *** [cartographer_pbstream] Error 1
CMakeFiles/Makefile2:395: recipe for target 'CMakeFiles/cartographer_pbstream.dir/all' failed

Help! I have met the same problem, even if I did it as "Confirmed on my end: if I add back what was removed from AbseilConfigureCopts.make in commit c695489 then it works."

@wsp666
Copy link

wsp666 commented Jun 22, 2022

[ 56%] Linking CXX executable cartographer_print_configuration CMakeFiles/cartographer_print_configuration.dir/cartographer/common/print_configuration_main.cc.o: In function cartographer::common::PrintSubdictionaryById(cartographer::common::LuaParameterDictionary*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)': print_configuration_main.cc:(.text+0x244): undefined reference to absl::ByChar::Find(std::basic_string_view<char, std::char_traits >, unsigned long) const' print_configuration_main.cc:(.text+0x65c): undefined reference to absl::ByChar::Find(std::basic_string_view<char, std::char_traits<char> >, unsigned long) const' CMakeFiles/cartographer_print_configuration.dir/cartographer/common/print_configuration_main.cc.o: In function absl::strings_internal::Splitter<absl::ByChar, absl::SkipEmpty, std::basic_string_view<char, std::char_traits > >::ConvertToContainer<std::vector<std::basic_string_view<char, std::char_traits >, std::allocator<std::basic_string_view<char, std::char_traits > > >, std::basic_string_view<char, std::char_traits >, false>::operator()(absl::strings_internal::Splitter<absl::ByChar, absl::SkipEmpty, std::basic_string_view<char, std::char_traits > > const&) const': print_configuration_main.cc:(.text.ZNK4absl16strings_internal8SplitterINS_6ByCharENS_9SkipEmptyESt17basic_string_viewIcSt11char_traitsIcEEE18ConvertToContainerISt6vectorIS7_SaIS7_EES7_Lb0EEclERKS8[ZNK4absl16strings_internal8SplitterINS_6ByCharENS_9SkipEmptyESt17basic_string_viewIcSt11char_traitsIcEEE18ConvertToContainerISt6vectorIS7_SaIS7_EES7_Lb0EEclERKS8]+0xc8): undefined reference to absl::ByChar::Find(std::basic_string_view<char, std::char_traits<char> >, unsigned long) const' print_configuration_main.cc:(.text._ZNK4absl16strings_internal8SplitterINS_6ByCharENS_9SkipEmptyESt17basic_string_viewIcSt11char_traitsIcEEE18ConvertToContainerISt6vectorIS7_SaIS7_EES7_Lb0EEclERKS8_[_ZNK4absl16strings_internal8SplitterINS_6ByCharENS_9SkipEmptyESt17basic_string_viewIcSt11char_traitsIcEEE18ConvertToContainerISt6vectorIS7_SaIS7_EES7_Lb0EEclERKS8_]+0x194): undefined reference to absl::ByChar::Find(std::basic_string_view<char, std::char_traits >, unsigned long) const' collect2: error: ld returned 1 exit status CMakeFiles/cartographer_print_configuration.dir/build.make:153: recipe for target 'cartographer_print_configuration' failed make[2]: *** [cartographer_print_configuration] Error 1 CMakeFiles/Makefile2:421: recipe for target 'CMakeFiles/cartographer_print_configuration.dir/all' failed make[1]: *** [CMakeFiles/cartographer_print_configuration.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs.... libcartographer.a(histogram.cc.o): In function cartographer::common::Histogram::ToString[abi:cxx11](int) const': histogram.cc:(.text+0x310): undefined reference to absl::strings_internal::CatPieces[abi:cxx11](std::initializer_list<std::basic_string_view<char, std::char_traits > >)' histogram.cc:(.text+0x778): undefined reference to `absl::strings_internal::AppendPieces(std::__cxx11::basic_string<char, std::char_traits, std::allocator >*, std::initializer_list<std::basic_string_view<char, std::char_traits > >)' collect2: error: ld returned 1 exit status CMakeFiles/cartographer_pbstream.dir/build.make:153: recipe for target 'cartographer_pbstream' failed make[2]: *** [cartographer_pbstream] Error 1 CMakeFiles/Makefile2:395: recipe for target 'CMakeFiles/cartographer_pbstream.dir/all' failed

Help! I have met the same problem, even if I did it as "Confirmed on my end: if I add back what was removed from AbseilConfigureCopts.make in commit c695489 then it works."

Help! I have met the same problem, Have you solve it?

@lanctot
Copy link
Author

lanctot commented Jun 22, 2022

@iDonghq @wsp666

The version of abseil being referred to in this thread is more than 2 years old and the problem has been fixed long ago. Do you not have the option to use a newer version of abseil?

@wsp666
Copy link

wsp666 commented Jun 22, 2022

Yes, when I try to install cartographyer, I should install abseil. I try to install it via official script:

set -o errexit
set -o verbose

git clone https://github.com/abseil/abseil-cpp.git
cd abseil-cpp
git checkout d902eb869bcfacc1bad14933ed9af4bed006d481
mkdir build
cd build
cmake -G Ninja \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
  -DCMAKE_INSTALL_PREFIX=/usr/local/stow/absl \
  ..
ninja
sudo ninja install
cd /usr/local/stow
sudo stow absl

but I failed! so I commented git checkout d902eb869bcfacc1bad14933ed9af4bed006d481 to maintain the latest version absl. It had not worked out yet. As follows:

Linking CXX executable cartographer_pbstream
FAILED: cartographer_pbstream 
: && /usr/bin/c++  -O3 -DNDEBUG  -rdynamic CMakeFiles/cartographer_pbstream.dir/cartographer/io/pbstream_main.cc.o  -o cartographer_pbstream  libcartographer.a  /usr/local/lib/libceres.a  -lglog  /usr/lib/x86_64-linux-gnu/libspqr.so  /usr/lib/x86_64-linux-gnu/libcholmod.so  /usr/lib/x86_64-linux-gnu/libamd.so  /usr/lib/x86_64-linux-gnu/libcamd.so  /usr/lib/x86_64-linux-gnu/libccolamd.so  /usr/lib/x86_64-linux-gnu/libcolamd.so  /usr/lib/x86_64-linux-gnu/libsuitesparseconfig.so  -lrt  /usr/lib/x86_64-linux-gnu/libtbb.so.2  /usr/lib/x86_64-linux-gnu/libcxsparse.so  -llapack  -lblas  -llua5.2  -lm  /usr/lib/x86_64-linux-gnu/libboost_iostreams.so.1.71.0  -lglog  /usr/lib/x86_64-linux-gnu/libgflags.so.2.2.2  -lcairo  -lprotobuf  /usr/local/lib/libabsl_leak_check.a  /usr/local/lib/libabsl_cord.a  /usr/local/lib/libabsl_cordz_info.a  /usr/local/lib/libabsl_cord_internal.a  /usr/local/lib/libabsl_cordz_functions.a  /usr/local/lib/libabsl_cordz_handle.a  /usr/local/lib/libabsl_hash.a  /usr/local/lib/libabsl_city.a  /usr/local/lib/libabsl_bad_variant_access.a  /usr/local/lib/libabsl_low_level_hash.a  /usr/local/lib/libabsl_raw_hash_set.a  /usr/local/lib/libabsl_bad_optional_access.a  /usr/local/lib/libabsl_hashtablez_sampler.a  /usr/local/lib/libabsl_exponential_biased.a  /usr/local/lib/libabsl_str_format_internal.a  /usr/local/lib/libabsl_synchronization.a  /usr/local/lib/libabsl_stacktrace.a  /usr/local/lib/libabsl_graphcycles_internal.a  /usr/local/lib/libabsl_symbolize.a  /usr/local/lib/libabsl_malloc_internal.a  /usr/local/lib/libabsl_debugging_internal.a  /usr/local/lib/libabsl_demangle_internal.a  /usr/local/lib/libabsl_time.a  /usr/local/lib/libabsl_strings.a  /usr/local/lib/libabsl_strings_internal.a  /usr/local/lib/libabsl_base.a  -lpthread  /usr/local/lib/libabsl_spinlock_wait.a  -lrt  /usr/local/lib/libabsl_throw_delegate.a  /usr/local/lib/libabsl_raw_logging_internal.a  /usr/local/lib/libabsl_log_severity.a  /usr/local/lib/libabsl_int128.a  /usr/local/lib/libabsl_civil_time.a  /usr/local/lib/libabsl_time_zone.a  -lpthread && :
/usr/bin/ld: libcartographer.a(histogram.cc.o): in function `cartographer::common::Histogram::ToString[abi:cxx11](int) const':
histogram.cc:(.text+0x43c): undefined reference to `absl::strings_internal::CatPieces[abi:cxx11](std::initializer_list<std::basic_string_view<char, std::char_traits<char> > >)'
/usr/bin/ld: histogram.cc:(.text+0x95a): undefined reference to `absl::strings_internal::AppendPieces(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, std::initializer_list<std::basic_string_view<char, std::char_traits<char> > >)'
collect2: error: ld returned 1 exit status
[257/387] Building CXX object CMakeFiles/cartographer.mapping.internal.3d.scan_matching.fast_correla...d_test.dir/cartographer/mapping/internal/3d/scan_matching/fast_correlative_scan_matcher_3d_test.cc.o
ninja: build stopped: subcommand failed.
<== Failed to process package 'cartographer': 
  Command '['ninja', '-j16', '-l16']' returned non-zero exit status 1.

Reproduce this error by running:
==> cd /home/wsp/catkin_ws/build_isolated/cartographer && ninja -j16 -l16

Command failed, exiting.

@iDonghq @wsp666

The version of abseil being referred to in this thread is more than 2 years old and the problem has been fixed long ago. Do you not have the option to use a newer version of abseil?

@lanctot
Copy link
Author

lanctot commented Jun 22, 2022

Hmm .. try setting the checkout command to the commit which fixed this problem which is (probably) only slightly newer? (you can find that commit number above, but I pasted it below):

set -o errexit
set -o verbose

git clone https://github.com/abseil/abseil-cpp.git
cd abseil-cpp
git checkout 7853a7586c492ce8905c9e49f8679dada6354f2c
mkdir build
cd build
cmake -G Ninja \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
  -DCMAKE_INSTALL_PREFIX=/usr/local/stow/absl \
  ..
ninja
sudo ninja install
cd /usr/local/stow
sudo stow absl

@lanctot
Copy link
Author

lanctot commented Jun 22, 2022

Also I think you should file a bug on ninja's github, and point them to this thread if you haven't already. It might be a known problem which has a fix or they could provide one.

@wsp666
Copy link

wsp666 commented Jun 22, 2022

Also I think you should file a bug on ninja's github, and point them to this thread if you haven't already. It might be a known problem which has a fix or they could provide one.

Thanks for your advice. I tried to use the only slightly newer, but failed yet. Maybe the problem comes from ninja.

@liuming706
Copy link

The problem doesn't comes from ninja, I didn't use ninja but it also occer the same problem

@liuming706
Copy link

The problem doesn't comes from ninja, I didn't use ninja but it also occer the same problem

Amazing! When I checkout to c695489,then cmake ..,make ,sudo cmake install ,it works very good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants