2

I am compiling HPX (a high performance computing library) in macos and it uses Boost. I am using clang 10 with meson as the build system. Using nm to dump the library and the application binary to inspect the symbols, I found that there is a one letter difference between them. The application that I am building, as the beginning of my learning path, is the HPX hello world example in the official documentation.

In libboost_filesystem-mt.dylib the symbol is __ZN5boost10filesystem6detail28directory_iterator_constructERNS0_18directory_iteratorERKNS0_4pathEjPNS_6system10error_codeE

and in the application it is __ZN5boost10filesystem6detail28directory_iterator_constructERNS0_18directory_iteratorERKNS0_4pathEPNS_6system10error_codeE

The only difference is a j character added after the path part of the mangled name in libboost_filesystem-mt.dylib. Why does this happen and what can I do about it? It is beyond my knowledge and any help will be profoundly appreciated. Thanks.

Angelo
  • 51
  • 1
  • 5

2 Answers2

2

According to the excellent https://demangler.com/, the first of these demangles to:

_boost::filesystem::detail::directory_iterator_construct(boost::filesystem::directory_iterator&, boost::filesystem::path const&, unsigned int, boost::system::error_code*)

and the second to:

_boost::filesystem::detail::directory_iterator_construct(boost::filesystem::directory_iterator&, boost::filesystem::path const&, boost::system::error_code*)

And you can now see that the difference is an extra unsigned int parameter in the first version. Why that should be I don't know, but maybe that gives you some clue as to what is going on.

Paul Sanders
  • 24,133
  • 4
  • 26
  • 48
  • 1
    I suspect that the difference is caused by having two different versions of Boost. Boost 1.72 added the `unsigned int` parameter. – ioums Dec 09 '20 at 22:25
2

Thank you guys. I was able to see that the symbols indeed refer to two different constructors for directory_iterator with the help of c++filt. I then inspected the HPX source code and found the only two places in one source file where the iterator is instantiated. I changed the code adding a boost::system::error_code variable to the constructor and it is now working perfectly. Since the new unsigned int parameter is the middle parameter, adding the error code variable to the constructor disambiguated it. This is how it is used now:

boost::system::error_code dir_ec;
for (fs::directory_iterator dir(libs_path, dir_ec); dir != notier; ++dir) {...}

I will open a pull request at the GitHub's project. It is a very nice library for HPC.

Angelo
  • 51
  • 1
  • 5