haampie / libtree

ldd as a tree
MIT License
2.63k stars 60 forks source link

Issues building on debian 10 #44

Closed woodensquares closed 2 years ago

woodensquares commented 2 years ago

in order to get libtree to build I had to do the following, it seems to work fine but I am not sure how applicable this is to other distributions so I am just opening an issue instead of a PR

diff --git a/src/deps.cpp b/src/deps.cpp
index c282a42..4f1978c 100644
--- a/src/deps.cpp
+++ b/src/deps.cpp
@@ -4,6 +4,7 @@
 #include <elfio/elfio_dump.hpp>
 #include <termcolor/termcolor.hpp>

+#include <iterator>
 #include <variant>

 bool is_lib(fs::path const &p) {
diff --git a/src/elf.cpp b/src/elf.cpp
index e32163d..a74e18b 100644
--- a/src/elf.cpp
+++ b/src/elf.cpp
@@ -77,7 +77,7 @@ std::optional<Elf> from_path(deploy_t type, found_t found_via, fs::path path_str
     if (!elf.load(path_str.string()))
         return std::nullopt;

-    auto elf_type = elf.get_class() == ELFCLASS64 ? elf_type_t::ELF_64 
+    auto elf_type = elf.get_class() == ELFIO::ELFCLASS64 ? elf_type_t::ELF_64 
                                                   : elf_type_t::ELF_32;

     // Check for mismatch between 64 and 32 bit ELF files.
@@ -87,7 +87,7 @@ std::optional<Elf> from_path(deploy_t type, found_t found_via, fs::path path_str
     // Loop over the sections
     for (ELFIO::Elf_Half i = 0; i < elf.sections.size(); ++i) {
         ELFIO::section* sec = elf.sections[i];
-        if ( SHT_DYNAMIC != sec->get_type() )
+        if ( ELFIO::SHT_DYNAMIC != sec->get_type() )
             continue;

         ELFIO::dynamic_section_accessor dynamic(elf, sec);
@@ -104,21 +104,21 @@ std::optional<Elf> from_path(deploy_t type, found_t found_via, fs::path path_str
             std::string str;
             dynamic.get_entry(i, tag, value, str);

-            if (tag == DT_NEEDED) {
+            if (tag == ELFIO::DT_NEEDED) {
                 needed.push_back(str);
-            } else if (tag == DT_RUNPATH) {
+            } else if (tag == ELFIO::DT_RUNPATH) {
                 for (auto const &path : split_paths(str))
                     runpaths.push_back(apply_substitutions(path, cwd, elf_type, platform));
-            } else if (tag == DT_RPATH) {
+            } else if (tag == ELFIO::DT_RPATH) {
                 for (auto const &path : split_paths(str))
                     rpaths.push_back(apply_substitutions(path, cwd, elf_type, platform));
-            } else if (tag == DT_SONAME) {
+            } else if (tag == ELFIO::DT_SONAME) {
                 name = str;
-            } else if (tag == DT_NULL) {
+            } else if (tag == ELFIO::DT_NULL) {
                 break;
             }
         }
     }

     return Elf{type, found_via, elf_type, name, path_str, runpaths, rpaths, needed};
-}
\ No newline at end of file
+}
haampie commented 2 years ago

You might want to try the 3.x version now

woodensquares commented 2 years ago

sorry for the delay in answering, 3.x works great, thanks!