Search code examples
c++compiler-errorslibrariesstack-trace

Backward cpp can no longer build, missing lbdf despite linking


I am on arch and made the mistake of upgrading.

Before I could build bacward-cpp, now I get the following error:

../libraries/backward-cpp/backward.hpp:1357:10: error: ‘bfd_get_section_flags’ was not declared in this scope; did you mean ‘bfd_set_section_flags’?
 1357 |     if ((bfd_get_section_flags(fobj.handle.get(), section) & SEC_ALLOC) == 0)
      |          ^~~~~~~~~~~~~~~~~~~~~
      |          bfd_set_section_flags
../libraries/backward-cpp/backward.hpp:1360:24: error: ‘bfd_get_section_vma’ was not declared in this scope; did you mean ‘bfd_set_section_vma’?
 1360 |     bfd_vma sec_addr = bfd_get_section_vma(fobj.handle.get(), section);
      |                        ^~~~~~~~~~~~~~~~~~~
      |                        bfd_set_section_vma
../libraries/backward-cpp/backward.hpp:1361:26: error: ‘bfd_get_section_size’ was not declared in this scope; did you mean ‘bfd_set_section_size’?
 1361 |     bfd_size_type size = bfd_get_section_size(section);
      |                          ^~~~~~~~~~~~~~~~~~~~
      |                          bfd_set_section_size
make[1]: *** [VulkanEngine.make:233: obj/Debug/VulkanDebugging.o] Error 1
make: *** [Makefile:30: VulkanEngine] Error 2

I am linking with both lbdf and ldl, by doing -lbfd -ldl as arguments to g++. I am also doing #define BACKWARD_HAS_BFD 1 before including the header as per the documentation.

I am at a loss.


Solution

  • The corresponding macros of binutils changed slightly.

    You have to drop the _get from the section macros and remove the fobj.handle.get() parameter manually: bfd_get_section_flags(fobj.handle.get(), section) to bfd_section_flags(section).