2

I build Gource project. Compile error comes when doing make.

g++ -std=gnu++0x -Wall -Wno-sign-compare -Wno-reorder -Wno-unused-but-set-variable -Wno-unused-variable -g -O2 -pthread -pthread -o gource src/gource-action.o src/gource-bloom.o src/gource-caption.o src/core/gource-conffile.o src/core/gource-display.o src/core/gource-frustum.o src/core/gource-fxfont.o src/core/gource-logger.o src/core/gource-mousecursor.o src/core/gource-plane.o src/core/gource-ppm.o src/core/gource-quadtree.o src/core/gource-regex.o src/core/gource-resource.o src/core/gource-sdlapp.o src/core/gource-seeklog.o src/core/gource-settings.o src/core/gource-shader.o src/core/gource-shader_common.o src/core/gource-stringhash.o src/core/gource-texture.o src/core/gource-png_writer.o src/core/gource-timezone.o src/core/gource-vbo.o src/core/gource-vectors.o src/gource-dirnode.o src/gource-file.o src/formats/gource-apache.o src/formats/gource-bzr.o src/formats/gource-commitlog.o src/formats/gource-custom.o src/formats/gource-cvs-exp.o src/formats/gource-cvs2cl.o src/formats/gource-git.o src/formats/gource-gitraw.o src/formats/gource-hg.o src/formats/gource-svn.o src/gource-gource.o src/gource-gource_shell.o src/gource-gource_settings.o src/gource-key.o src/gource-logmill.o src/gource-main.o src/gource-pawn.o src/gource-slider.o src/gource-spline.o src/gource-textbox.o src/gource-user.o src/gource-zoomcamera.o src/tinyxml/gource-tinyxmlerror.o src/tinyxml/gource-tinystr.o src/tinyxml/gource-tinyxml.o src/tinyxml/gource-tinyxmlparser.o -lGL -lGLU -lfreetype -lpcre -lGLEW -lGLU -lGL -lSDL2_image -lSDL2 -lpng15 -lboost_system -lboost_filesystem src/gource-gource_settings.o: In function boost::filesystem::path::path<boost::filesystem::directory_entry>(boost::filesystem::directory_entry const&, boost::enable_if<boost::filesystem::path_traits::is_pathable<boost::decay<boost::filesystem::directory_entry>::type>, void>::type*)': /usr/include/boost/filesystem/path.hpp:139: undefined reference to boost::filesystem::path_traits::dispatch(boost::filesystem::directory_entry const&, std::__cxx11::basic_string<char, std::char_traits, std::allocator >&, std::codecvt<wchar_t, char, __mbstate_t> const&)' collect2: error: ld returned 1 exit status

Build enviroment use libboost_filesystem.so.1.53.0.

⋊> /h/m/Gource on master ◦  ll /usr/lib64/libboost_filesystem.so                                                                                                                                                                                        18:26:31
lrwxrwxrwx. 1 root root 29 Sep 27  2020 /usr/lib64/libboost_filesystem.so -> libboost_filesystem.so.1.53.0*

I use strings to dig libboost_filesystem.so.1.53.0 and find symbol like boost::filesystem::path_traits::dispatch.

⋊> /h/m/Gource on master ◦  strings /usr/lib64/libboost_filesystem-mt.so | grep path_traits                                                                                                                                                             18:29:50
_ZN5boost10filesystem11path_traits8dispatchERKNS0_15directory_entryERSsRKSt7codecvtIwc11__mbstate_tE
_ZN5boost10filesystem11path_traits7convertEPKcS3_RSbIwSt11char_traitsIwESaIwEERKSt7codecvtIwc11__mbstate_tE
_ZN5boost10filesystem11path_traits7convertEPKwS3_RSsRKSt7codecvtIwc11__mbstate_tE

find symbol:

> ⋊> /h/m/Gource on master ◦ nm -DC /usr/lib64/libboost_filesystem.so | grep dispatch
0000000000007800 T boost::filesystem::path_traits::dispatch(boost::filesystem::directory_entry const&, std::string&, std::codecvt<wchar_t, char, __mbstate_t> const&)

Library shows like this:

⋊> /h/m/Gource on master ◦  ls /usr/lib64/libboost_filesystem.so* -l                                                                                                                                                                                    19:22:03
lrwxrwxrwx. 1 root root     29 Sep 27  2020 /usr/lib64/libboost_filesystem.so -> libboost_filesystem.so.1.53.0*
-rwxr-xr-x. 1 root root  94760 Apr  1  2020 /usr/lib64/libboost_filesystem.so.1.53.0*
-rwxr-xr-x. 1 root root 103592 Apr 24  2019 /usr/lib64/libboost_filesystem.so.1.69.0*

What's this compile error meaning? Thanks in advance.

mariolu
  • 624
  • 8
  • 17
  • Hmm I don't recognize this `/usr/lib64/` lib directory, what is your system? Can you execute `nm -DC /usr/lib64/libboost_filesystem.so | grep dispatch`? Are you sure you don't have any boost conflicting versions in your system, or somewhere in the local directory? – pptaszni May 05 '21 at 11:12
  • ⋊> /h/m/Gource on master ◦ nm -DC /usr/lib64/libboost_filesystem.so | grep dispatch 118:51:14 0000000000007800 T boost::filesystem::path_traits::dispatch(boost::filesystem::directory_entry const&, std::string&, std::codecvt const&) – mariolu May 05 '21 at 11:21
  • @pptaszni hi pptaszni. I use -l:libboost_system.so.1.53.0 to clarify exact path, the same error comes. – mariolu May 05 '21 at 11:24

1 Answers1

5

Your library has this symbol:

boost::filesystem::path_traits::dispatch(boost::filesystem::directory_entry const&, std::string&, std::codecvt<wchar_t, char, __mbstate_t> const&)

But your linker is looking for this:

boost::filesystem::path_traits::dispatch(boost::filesystem::directory_entry const&, std::__cxx11::basic_string<char, std::char_traits, std::allocator >&, std::codecvt<wchar_t, char, __mbstate_t> const&)

The difference is std::string aka std::basic_string in your .so file, but std::__cxx11::basic_string in your application.

When C++11 was standardized, GCC had to change their std::string implementation. They did this in GCC 5. I suppose you have GCC 5 or newer. You can tell GCC to use the old ABI by compiling with -D _GLIBCXX_USE_CXX11_ABI=0, then it will be compatible with the libraries you have installed. Or you can install new Boost libraries built with GCC 5 or later. Maybe the Boost 1.69.0 library you have installed uses the new ABI, you can try nm on it to find out.

See: Understanding GCC 5's _GLIBCXX_USE_CXX11_ABI or the new ABI

John Zwinck
  • 239,568
  • 38
  • 324
  • 436