Fresh install noob trouble compiling SDL2 w/ sound version

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

    Fresh install noob trouble compiling SDL2 w/ sound version

    Blew away my Angband and MSYS2 installs and am trying to recompile, and having some trouble. Any help would be appreciated. : D

    I'm doing this:

    ~~~
    Download the latest MSYS2 self-extracting archive (*sfx.exe) from https://github.com/msys2/msys2-installer/releases. Running it auto-extracts to an "msys64" folder in the same directory as the *sfx.exe. 'p' Go in there and run msys2.exe (the purple one); it will auto-update. Once that's finished, enter:

    Code:
    pacman -Syu --noconfirm
    (when it closes, relaunch)
    Code:
    pacman -Syu --noconfirm
    pacman -S git
    Then from the Angband manual's compiling instructions ( https://angband.readthedocs.io/en/la...2-with-mingw64 ):
    Code:
    pacman -S make mingw-w64-x86_64-toolchain mingw-w64-x86_64-ncurses
    pacman -S mingw-w64-x86_64-SDL2 mingw-w64-x86_64-SDL2_image
    pacman -S mingw-w64-x86_64-SDL2_ttf mingw-w64-x86_64-SDL2_mixer
    Then
    Code:
    git clone https://github.com/angband/angband.git
    cd angband
    From the manual again:
    Code:
    cd src
    make -f Makefile.msys2.sdl2 SOUND=yes
    ~~~~

    Currently that last command returns

    make: sdl2-config: No such file or directory
    make: sdl2-config: No such file or directory
    make: sdl2-config: No such file or directory
    make: sdl2-config: No such file or directory
    CC main.c
    make: gcc: No such file or directory
    make: *** [Makefile.msys2.sdl2:133: main.o] Error 127
    ~~~~

    (I was surprised by this because when I was trying this yesterday, I got past that part and got a compile error at something like missing SDL .h something or other. Maybe I had separately installed gcc at that point, I dunno. Was trying to follow the strict instructions this time.)

    (By the way, is the "mingw-w64-x86_64-ncurses" in the manual's compiling instructions necessary? It looks like ncurses is installed by toolchain.)
    Last edited by smbhax; February 20, 2024, 03:33.
    My Angband videos
  • backwardsEric
    Knight
    • Aug 2019
    • 527

    #2
    It sounds like /mingw64/bin is not in your path (running "echo $PATH" would confirm that). According to this question on Stack Overflow, https://stackoverflow.com/questions/...the-msys2-path , that can happen if you use msys2.exe rather than mingw64.exe to start up MSYS2.

    mingw-w64-x86_64-ncurses is only necessary if you want to build the ncurses front end with Makefile.msys2 . It does look like installing the toolchain installs it because gdb has it as a dependency. I would leave it as something to install in Angband's compilation instructions (if the compilation works using mingw-w64-x86_64-gcc rather than mingw-w64-x86_64-toolchain could use that in the instructions).

    Comment

    • smbhax
      Swordsman
      • Oct 2021
      • 340

      #3
      Ah man yeah I sure got to thinking it was the purple msys2.exe rather than the blue mingw64.exe I used to use, and I was definitely wrong. Why do they give me multiple exes I can't handle it. Heck I'm going to delete those other ones, don't tell anyone. Ooh I suppose it might rebuild them at some point oh well.

      Okay fresh install I ran mingw64.exe this time and did

      Code:
      pacman -S make mingw-w64-x86_64-gcc mingw-w64-x86_64-ncurses
      pacman -S mingw-w64-x86_64-SDL2 mingw-w64-x86_64-SDL2_image
      pacman -S mingw-w64-x86_64-SDL2_ttf mingw-w64-x86_64-SDL2_mixer
      (gcc instead of toolchain) and the other stuff and that worked, compile success! Thanks!! = DD

      When I double-click the compiled Angband.exe, I get four successive pop-up Windows "angband.exe - System Error" messages:

      The code execution cannot proceed because SDL2.dll was not found. Reinstalling the program may fix this problem.
      followed by similar error messages for missing SDL2_image.dll, SDL2_mixer.dll, and SDL2_ttf.dll--and Angband does not launch.

      A file search finds those four dlls in C:\downloaded\msys2\mingw64\bin. My angband.exe built in C:\downloaded\msys2\home\smbhax\angband

      Did the Makefile used to copy them in there? Did I copy them in there manually before? Or have some script that told the program where to find them or to build them in or whatnot? I don't remember.

      Oh, Angband does launch if I just use "./angband.exe -uPLAYER" from the /angband directory in MSYS2's console. But I used to use a Windows shortcut to the exe. I've still got that old shortcut. ^ _^ Hmm...

      (And Angband isn't playing any sounds, like when I bump my @ into walls. AH it's off by default, haha. Have to do =ab[Enter](s) to turn sound on in the game options. ; D)

      If I put the four SDL2 dlls in with the exe and run from the Windows shortcut again, now it says it's missing libmpg123-0.dll, libopusfile-0.dll, libavif-16.dll, and libjpeg-8.dll. I don't think I remember those.

      If I copy THOSE in with the exe and try the Windows shortcut again...another four dlls are listed as missing. Well heck, pretty sure I never copied THAT many dlls over before. I must'a had something else telling it where the dlls were, darned if I remember what though.
      Last edited by smbhax; February 20, 2024, 08:41.
      My Angband videos

      Comment

      • smbhax
        Swordsman
        • Oct 2021
        • 340

        #4
        Might have something to do with this change from December?

        A free, single-player roguelike dungeon exploration game - MSYS2: link SDL2 DLLs so dependencies do not have to be specified angband/angband@9dca513
        My Angband videos

        Comment

        • backwardsEric
          Knight
          • Aug 2019
          • 527

          #5
          Yes, after that change, SDL2 and its dependencies are dynamically linked to the executable (and have to be found at runtime, the change did not handle that). They had been previously statically linked. Setting up a batch file to run angband.exe would be a way to avoid copying over all the dependent DLLs. I think this would work: create angband.bat in the same directory as angband.exe and fill it with

          Code:
          path %path%;C:\msys64\mingw64\bin
          angband.exe
          . You may be able to do the same in a shortcut with the shortcut set to something like this (replace full_path_to_angband with the path for the directory containing angband.exe)

          Code:
          C:\Windows\System32\cmd.exe /c "path %path%;C:\msys64\mingw64\bin && full_path_to_angband\angband.exe"

          Comment

          • smbhax
            Swordsman
            • Oct 2021
            • 340

            #6
            I'll have to give that a shot, hopefully it'll let me pin the shortcut to the taskbar, since that's where I like to put them.

            It still wouldn't be a portable build though, would it? I thought part of the whole thing about MINGW64 or whatever was being able to generate portable code. Is there a reason it has to be dynamically linked now?
            My Angband videos

            Comment

            • smbhax
              Swordsman
              • Oct 2021
              • 340

              #7
              This feels really discouraging.

              I'm really not interested in building a non-portable .exe. I had someone ask me to do a video tutorial on building SDL2-with-sound Angband but having to say "oh and then you go and copy over these ~35 dlls, may change without warning in the future," doesn't feel viable.
              Last edited by smbhax; February 20, 2024, 19:33.
              My Angband videos

              Comment

              • backwardsEric
                Knight
                • Aug 2019
                • 527

                #8
                Originally posted by smbhax
                It still wouldn't be a portable build though, would it? I thought part of the whole thing about MINGW64 or whatever was being able to generate portable code. Is there a reason it has to be dynamically linked now?
                With the dynamically linked executable, copying the executable (and the lib directory as well) to another system would not work unless that system had MSYS2 and the necessary libraries installed or the necessary DLLs are copied over as well. It looks like there's an open source project, https://github.com/brechtsanders/pedeps , that could automate copying the dependencies, but that would be an extra thing to install, prior to building Angband.

                Dynamically linking the executable makes Makefile.msys2.sdl2 less fragile: with static linking it has to be updated frequently (it was 2-3 times per year in 2022 and 2023) as the dependencies for the SDL2 libraries change.

                If making a redistributable executable is what the community wants from Makefile.msys2.sdl2, then the dynamic linking in Makefile.msys2.sdl2 could be reverted.







                Comment

                • smbhax
                  Swordsman
                  • Oct 2021
                  • 340

                  #9
                  Speaking purely selfishly since I don't actually do any of the work, to me it seems like keeping the dependencies up to date should be part of maintaining the project.

                  Does this change mean SDL2 is no longer being considered as the front end for official Windows releases of Angband at some point?

                  Anyway, I guess I'll just give the person who asked me the list of directions for building and running from the terminal.
                  My Angband videos

                  Comment

                  • backwardsEric
                    Knight
                    • Aug 2019
                    • 527

                    #10
                    This pull request, https://github.com/angband/angband/pull/5907 , restores static linking of SDL2 in Makefile.msys2.sdl2.

                    Comment

                    • Nick
                      Vanilla maintainer
                      • Apr 2007
                      • 9634

                      #11
                      Originally posted by smbhax
                      Speaking purely selfishly since I don't actually do any of the work, to me it seems like keeping the dependencies up to date should be part of maintaining the project.
                      Technically this is true, and as the named maintainer it's down to me. In practice, I have done pretty much none of the work on the SDL2 port, and (like many parts of Angband) it was contributed by someone who is not a regular part of the maintenance cycle. In fact, you should be bowing down and giving thanks to backwardsEric for all his work on the SDL2 port (and many other aspects of the game, in fact), because if it had been left to me it would still be in an almost unplayable state.

                      I could go on at length about the ins and outs of maintaining a project like Angband, but I won't
                      One for the Dark Lord on his dark throne
                      In the Land of Mordor where the Shadows lie.

                      Comment

                      • smbhax
                        Swordsman
                        • Oct 2021
                        • 340

                        #12
                        Thanks guys! I really appreciate your hard work and patience with my foolishness and ignorance, as always. ^ _^

                        Uh speaking of which, I'm having some trouble with this latest bunch of Angband commits. I've tried a fresh MSYS2 install and Angband SDL2-with-sound build from them, following the same steps as above except now leaving out ncurses--so just

                        Code:
                        pacman -S make mingw-w64-x86_64-gcc
                        for that one line from the manual (which doesn't appear to have been updated from that .rst commit yet https://angband.readthedocs.io/en/la...2-with-mingw64 ), and it compiles without error, but the resulting angband.exe does not open a game window when run; the process appears for a moment in Task Manager, then disappears with no error message, whether run with "./angband.exe -uPLAYER" from the MSYS2 mingw64 terminal, or from a Windows shortcut with "-uPLAYER" added to the Target field.

                        Have run through a full from-scratch MSYS2 install on this twice, same non-result. Probably I'm doing something new wrong, but I dunno.

                        Ah okay the second time, I first tried it from the terminal, and it gave a "Segmentation fault" response. Subsequent attempts produce no message.

                        smbhax@DESKTOP-64GQN1N MINGW64 ~/angband
                        $ ./angband.exe -uPLAYER
                        Segmentation fault

                        smbhax@DESKTOP-64GQN1N MINGW64 ~/angband
                        $ ./angband.exe

                        smbhax@DESKTOP-64GQN1N MINGW64 ~/angband
                        $ ./angband.exe -uPLAYER

                        smbhax@DESKTOP-64GQN1N MINGW64 ~/angband
                        $ ./angband.exe -uPLAYER

                        smbhax@DESKTOP-64GQN1N MINGW64 ~/angband
                        $
                        The angband.exe is 46.7 MB.
                        Last edited by smbhax; February 22, 2024, 01:31.
                        My Angband videos

                        Comment

                        • backwardsEric
                          Knight
                          • Aug 2019
                          • 527

                          #13
                          From what I can see, replacing -lntoskrnl with -lntdll at line 82 of Makefile.msys2.sdl2 and then relinking (remove src/angband.exe and then rerun "make -f Makefile.msys2.sdl2 SOUND=yes" in the src directory) avoids the crash at startup. That change is up as a pull request at https://github.com/angband/angband/pull/5909 .

                          As for the size of the executable, that's going to be price for statically linking all of the dependencies for SDL2.

                          Comment

                          • smbhax
                            Swordsman
                            • Oct 2021
                            • 340

                            #14
                            Yep, that gets it working!

                            I was just mentioning the .exe size in case that was relevant to the segmentation fault problem. ^ _^
                            My Angband videos

                            Comment

                            • Nick
                              Vanilla maintainer
                              • Apr 2007
                              • 9634

                              #15
                              That latest change is pulled in now.

                              Originally posted by smbhax
                              Thanks guys! I really appreciate your hard work and patience with my foolishness and ignorance, as always. ^ _^
                              Not much hard work from me at the moment
                              One for the Dark Lord on his dark throne
                              In the Land of Mordor where the Shadows lie.

                              Comment

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