Compiling Hengband: "fatal error: util.h: No such file or directory"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • smbhax
    Swordsman
    • Oct 2021
    • 340

    Compiling Hengband: "fatal error: util.h: No such file or directory"

    When compiling Hengband--the latest from the Hengband repo--in Cygwin, following the instructions for Unix here https://github.com/hengband/hengband.../readme-eng.md , I get an error:

    Code:
    io/uid-checker.cpp:6:10: fatal error: util.h: No such file or directory
        6 | #include "util.h"
    If I comment that include line in uid-checker.cpp out, Hengband compiles with no further errors, but running the generated .exe gives a "setuid(): cannot set permissions correctly!" error.

    There are a lot of files in the Hengband repo ending with "-util.h," but none named just "util.h." Could this be a typo in uid-checker.cpp, or a missing file?

    I'm a noob at this, sorry for the dumb question!
    My Angband videos
  • backwardsEric
    Knight
    • Aug 2019
    • 527

    #2
    That looks like a bug. I'd post an issue about it on Hengband's issue list. My guess as to why they haven't seen it when they compile for Linux is that SAFE_SETUID_POSIX somehow isn't set there while it is set on cygwin. Commenting out lines 51 to 53 of src/system/h-config.h (i.e. replace

    Code:
      #ifdef _POSIX_SAVED_IDS
        #define SAFE_SETUID_POSIX
      #endif
    with

    Code:
    #if 0
      #ifdef _POSIX_SAVED_IDS
        #define SAFE_SETUID_POSIX
      #endif
    #endif
    ) and recompiling may work around the problem.

    Comment

    • smbhax
      Swordsman
      • Oct 2021
      • 340

      #3
      Originally posted by backwardsEric
      That looks like a bug. I'd post an issue about it on Hengband's issue list. My guess as to why they haven't seen it when they compile for Linux is that SAFE_SETUID_POSIX somehow isn't set there while it is set on cygwin. Commenting out lines 51 to 53 of src/system/h-config.h (i.e. replace

      Code:
        #ifdef _POSIX_SAVED_IDS
          #define SAFE_SETUID_POSIX
        #endif
      with

      Code:
      #if 0
        #ifdef _POSIX_SAVED_IDS
          #define SAFE_SETUID_POSIX
        #endif
      #endif
      ) and recompiling may work around the problem.
      Thanks for taking a look! Tried that workaround, and the game compiles, but dies with "Fatal Error" when run.

      (There's also the odd issue that trying to run ./hengband gives a "is a directory" error; renaming /hengband/Hengband/ to something that is not "Hengband" seems to dodge that (looks like all that's in that directory are vc proj files?), but there's probably a less hacky way to do that.)

      I entered the "util.h" compiling error on their repo, and included your comment: https://github.com/hengband/hengband/issues/1971

      Update:

      They replied almost instantly, fixed my issue title (I'd overlooked it and left it as the Japanese placeholder text, urk), and said they would fix the problem: they've added it to their Alpha 52 milestone. : )
      My Angband videos

      Comment

      • smbhax
        Swordsman
        • Oct 2021
        • 340

        #4
        Hourier replied on their git to say
        I investigated this issue and found that util.h is not used any more.
        (quit() was defined in the header once but now it moved to z-util.cpp/h)

        So, would you please try to compile Hengband with uid-checker.cpp L3-9 (inclusion of util.h) removed?
        This file includes z-util.cpp/h indirectly (uid-checker.cpp => angband.h => z-util.h), so there may be no problem.
        I tried that--having reverted the comment to h-config.h--and the program compiled, but attempting to launch it gives "Fatal Error"--which I have reported to them.

        Actually, depending on how I try running it, it may say a few different things--I list these in the github issue. For instance, if I try "./hengband" from home/[username]/hengband/ (I have the game and /src/ etc in that folder I made--but I have to rename home/[username]/hengband/Hengband/ to home/[username]/hengband/zHengband/ or something first, otherwise I get "is a directory" : P), it responds with "setuid(): cannot set permissions correctly!"
        Last edited by smbhax; January 9, 2022, 16:53.
        My Angband videos

        Comment

        • backwardsEric
          Knight
          • Aug 2019
          • 527

          #5
          The most recent update to the master branch for Hengband has a change that may fix the problem you saw with escalating/dropping privileges on Cygwin. If you have a chance, it's probably worth trying it out and reporting the results on the issue you filed.

          The problem with the executable name clashing with the directory for the Visual Studio project files when the file system is case-insensitive is still there. Easiest workaround is likely to move the Hengband directory to another name before building.

          Comment

          • smbhax
            Swordsman
            • Oct 2021
            • 340

            #6
            Originally posted by backwardsEric
            The most recent update to the master branch for Hengband has a change that may fix the problem you saw with escalating/dropping privileges on Cygwin. If you have a chance, it's probably worth trying it out and reporting the results on the issue you filed.

            The problem with the executable name clashing with the directory for the Visual Studio project files when the file system is case-insensitive is still there. Easiest workaround is likely to move the Hengband directory to another name before building.
            Thanks! Looks like you've got that and the uid-checker thing fixed very neatly, the game runs now. =))))
            My Angband videos

            Comment

            • Gwarl
              Administrator
              • Jan 2017
              • 1025

              #7
              Managed to compile 3.0.0Alpha51 on my local machine, but when I try it on the angband.live server I run into this:

              In file included from /usr/include/c++/8/memory:80,
              from ./stdafx.h:9,
              from <command-line>:
              /usr/include/c++/8/bits/unique_ptr.h: In instantiation of ‘typename std::enable_if<std::is_convertible<_Up (*)[], _Tp (*)[]>::value>::type std::default_delete<_Tp []>:perator()(_Up*) const [with _Up = object_type; _Tp = object_type; typename std::enable_if<std::is_convertible<_Up (*)[], _Tp (*)[]>::value>::type = void]’:
              /usr/include/c++/8/bits/unique_ptr.h:537:17: required from ‘std::unique_ptr<_Tp [], _Dp>::~unique_ptr() [with _Tp = object_type; _Dp = std::default_delete<object_type []>]’
              ./store/store-util.h:49:42: required from here
              /usr/include/c++/8/bits/unique_ptr.h:113:16: error: invalid application of ‘sizeof’ to incomplete type ‘object_type’
              static_assert(sizeof(_Tp)>0,
              ^~~~~~~~~~~
              Makefile:4988: recipe for target 'birth/character-builder.o' failed
              I'm pretty stumped

              Comment

              • smbhax
                Swordsman
                • Oct 2021
                • 340

                #8
                I didn't run into anything like that either when compiling it on my own machine. Some difference in the compiler you're using on live? I hope you can get it working, it would definitely be nice to see there. : )
                My Angband videos

                Comment

                • backwardsEric
                  Knight
                  • Aug 2019
                  • 527

                  #9
                  Gwarl, I didn't encounter any problems compiling it on Debian bullseye (Debian's version of gcc 10.2.1 was the compiler). From GitHub's logs for Hengband's Actions, they're successfully compiling it on Ubuntu 20.04 LTS using clang-11 or gcc (gcc version is either 10.3 or 9.3 according to GitHub's summary of the installed software for the Ubuntu runner).

                  Did you try adding

                  Code:
                  #include "system/object-type-definition.h"
                  to src/birth/character-builder.cpp? That might be enough to satisfy unique_ptr's use of sizeof().

                  Comment

                  • Gwarl
                    Administrator
                    • Jan 2017
                    • 1025

                    #10
                    Thanks, that fixed it. I got a couple of other files needing the same fix, now I've run into this

                    knowledge/knowledge-items.cpp: In function �KIND_OBJECT_IDX collect_objects(int, KIND_OBJECT_IDX*, BIT_FLAGS8)’:
                    knowledge/knowledge-items.cpp:144:27: error: �reduce’ is not a member of �std’
                    auto k = std::reduce(std::begin(k_ref.chance), std::end(k_ref.chance), 0);
                    ^~~~~~
                    knowledge/knowledge-items.cpp:144:27: note: suggested alternative: �deque’
                    auto k = std::reduce(std::begin(k_ref.chance), std::end(k_ref.chance), 0);
                    ^~~~~~
                    deque
                    Makefile:4988: recipe for target 'knowledge/knowledge-items.o' failed
                    I suspect the compiler is too old, it's gcc 8.4 which is the latest available in the apt repositories available. Is there anything else I can try besides setting up a newer version?

                    Comment

                    • Gwarl
                      Administrator
                      • Jan 2017
                      • 1025

                      #11
                      I upgraded to g++ 11 and it compiled...

                      Comment

                      • backwardsEric
                        Knight
                        • Aug 2019
                        • 527

                        #12
                        Originally posted by Gwarl
                        I suspect the compiler is too old, it's gcc 8.4 which is the latest available in the apt repositories available. Is there anything else I can try besides setting up a newer version?
                        Perhaps replace std::reduce with std::accumulate? std::reduce was introduced in C++-17. std::accumulate should give the same result in this case (though perhaps be less efficient in compute time) and appears to be supported in older versions of the C++ standard.

                        Comment

                        • Gwarl
                          Administrator
                          • Jan 2017
                          • 1025

                          #13
                          3.0.0Alpha51 is up on angband.live but they're missing a few fixes, like support for a main window larger than 80x24 in the curses frontend. I'll see what I can do to fix it in the coming days.

                          Comment

                          • smbhax
                            Swordsman
                            • Oct 2021
                            • 340

                            #14
                            Nice! : )

                            The map size happened to fit nicely on my 1080p screen with a size 19 Droid Sans Mono in Cygwin, so I hadn't stopped to wonder about what was setting its parameters.

                            Hm, the loose cursor blipping around the subwindows is more pronounced in live, I suppose just standing out more due to the latency. It's something I reported to them, but they don't play in Curses over there due to language support--I think--so it doesn't sound like Curses-specific bugs will be a priority for them. https://github.com/hengband/hengband/issues/2014 I tried comparing the cursor-handling bits I could spot in their main-gcu.cpp with Angband's main-gcu.c, buuut it was just "Greek" with minor variations to my non-coder self.
                            My Angband videos

                            Comment

                            • smbhax
                              Swordsman
                              • Oct 2021
                              • 340

                              #15
                              (Aside from making the 00 00 FF TERM_BLUE color a slightly lighter 00 40 FF in src/term/gameterm.cpp so it isn't painfully dark to try to see, the other change I've made locally is to comment out the two "You failed to pick the lock" outcomes in src/action/open-close-execution.cpp, because bonking my face against random locked doors up to 69x so far just to open them was a bit much.)
                              My Angband videos

                              Comment

                              Working...
                              😀
                              😂
                              🥰
                              😘
                              🤢
                              😎
                              😞
                              😡
                              👍
                              👎