Windows Compiling and Makefiles

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • APWhite
    Adept
    • Jul 2007
    • 244

    Windows Compiling and Makefiles

    So you other Windows users, what are you using for compiling and debugging?

    I have used Borlands freecommandlinetools for years. It is nice that there is a makefile.bcc included in the old versions of the game. I see now that 308 is out there is no makefile for Borland. What are we to use for a compiler and / or command line makefiles?

    I also have Visual Studio 2005 but I have only used for PDA applications and have never been able to get it to understand how to use the angband code (so Solution or Project files).
    St George Chiropractor
    Angband Borg Homepage
  • ctate
    Rookie
    • Jul 2007
    • 18

    #2
    Building Angband with MSVC 2005

    Originally posted by APWhite
    So you other Windows users, what are you using for compiling and debugging?

    I have used Borlands freecommandlinetools for years. It is nice that there is a makefile.bcc included in the old versions of the game. I see now that 308 is out there is no makefile for Borland. What are we to use for a compiler and / or command line makefiles?

    I also have Visual Studio 2005 but I have only used for PDA applications and have never been able to get it to understand how to use the angband code (so Solution or Project files).
    Based on recent experiences I had at work with Borland's C/C++, I would not recommend using it. Ever. For anything.

    I believe the canonical Angband build system uses gcc. Directions for building under cygwin or with DevC++ are in the development wiki. It built for me pretty straightforwardly using this command line from the angband/src directory in cygwin:

    MINGW=yes make -f Makefile.win

    Right now, personally, I'm using VS2005 Express to take advantage of the debugging environment.

    To use VS2005, you need to have the Windows SDK installed as well. Create an empty Windows Application solution, then add all of the Angband src/*.c and src/win/*.c files, as well as the .rc and .ico files. Make sure that the symbol WINDOWS is defined as a compiler command-line option. In order for the resource compiler to find the .ico file at build time, you'll have to add the .ico file location to the include path. To use sound, you will need to add Winmm.lib as an additional library as well. (To build without sound support, comment out the line #define USE_SOUND in config.h.) You can also be fancy about a post-build event in order to copy the .exe to a useable spot so you can just double-click launch it and it will find the lib/ dir properly.

    --
    ctate
    Last edited by ctate; July 29, 2007, 04:40.

    Comment

    • ctate
      Rookie
      • Jul 2007
      • 18

      #3
      Non-cygwin Windows makefile added

      Okay, I just added a makefile to the V trunk for building the Windows version directly with Microsoft's NMAKE and MSVC toolchain, in a regular cmd.exe shell window. You go to the src/ subdirectory and type

      Code:
      NMAKE /F Makefile.nmake
      and it compiles a debug build of Angband.exe, and copies it up a level in the hierarchy so you can run it. To do an optimized build without debug information, use the command line

      Code:
      NMAKE /F Makefile.nmake RELEASE=1
      Right now the flags are suitable for compiling with MSVC version 6 and up. I'll add some variants later on that tune the build for MSVC 8+ ["Visual Studio 2005" is version 8]; I only have version 6 installed on the computer I'm using right now.

      Of course you'll need to have the Windows SDK installed and configured for command-line use, as well as the MSVC command-line toolchain. There's a batch file provided in the Visual Studio installation that configures the build environment for you, or you can set all the appropriate environment variables by hand.

      Comment

      • APWhite
        Adept
        • Jul 2007
        • 244

        #4
        Originally posted by ctate
        To use VS2005, you need to have the Windows SDK installed as well. Create an empty Windows Application solution, then add all of the Angband src/*.c and src/win/*.c files, as well as the .rc and .ico files. Make sure that the symbol WINDOWS is defined as a compiler command-line option. In order for the resource compiler to find the .ico file at build time, you'll have to add the .ico file location to the include path. To use sound, you will need to add Winmm.lib as an additional library as well. (To build without sound support, comment out the line #define USE_SOUND in config.h.) You can also be fancy about a post-build event in order to copy the .exe to a useable spot so you can just double-click launch it and it will find the lib/ dir properly.

        --
        ctate

        I am pretty sure that SDK is installed. I got it most of the way with your description above:

        I do not see where I can add the ICO file pathway. I added the pathway somewhere, but it did not find the file (eventhough it is present in the solution explorer). I copied the ICO file to the working directory and it found it fine.

        I was not able to get it to find the winmm.lib file. It is on my drive and under the Project->Preference->Common Properties->References->Reference Search Path, I added the location of the Winmm.lib file, but it still cant find it.

        As far as adding the commandline option WINDOWS, I am not sure I know where to do this. I added it toProject->Preference->Configuration Properties->Debugging->command arguments. I hope this is the right place.

        If you could verify this for me, I would greatly appreciate it. I need to use VS2005 in order to debug some Borg graphics issues. The BCC compiler/debugger won't work. The symbols table is too large to load in TD32.exe. It keeps pooping out so I can't effectively debug the angband borg. I thought it might be the Lua issues in 3.0.6. Maybe when I get the borg updated for 308/309, the symbols table will be smaller and I might be able to load it up.

        Andrew
        St George Chiropractor
        Angband Borg Homepage

        Comment

        • ctate
          Rookie
          • Jul 2007
          • 18

          #5
          Originally posted by APWhite
          I am pretty sure that SDK is installed. I got it most of the way with your description above:

          I do not see where I can add the ICO file pathway. I added the pathway somewhere, but it did not find the file (eventhough it is present in the solution explorer). I copied the ICO file to the working directory and it found it fine. [....]
          I'd suggest that you not worry about setting up a full-blown VS solution for now, and just try to build from the command line using the Makefile.nmake that I added to the source tree a few days ago in this post. Does that work for you? If so, you can run the executable alone from within the VS debugger, and that should work to get you started with debugging the current code.

          I can jot up more detailed instructions on how exactly I set up my VS2005 solution file, but that's at home so I don't have access right now.

          Comment

          • APWhite
            Adept
            • Jul 2007
            • 244

            #6
            Originally posted by ctate
            I'd suggest that you not worry about setting up a full-blown VS solution for now, and just try to build from the command line using the Makefile.nmake that I added to the source tree a few days ago in this post. Does that work for you? If so, you can run the executable alone from within the VS debugger, and that should work to get you started with debugging the current code.

            I can jot up more detailed instructions on how exactly I set up my VS2005 solution file, but that's at home so I don't have access right now.
            Thanks for the continued help. It will make a big difference for me later on, as I keep the Borg and screensaver updated.

            I ran into a few problems though. This was my trail:
            1. Download and unzip the src files.
            2. Download and unzip the \lib files
            3. Get you makefile.nmake
            4. In a cmd shell prompt typed Nmake /F makefile.nmake

            I am able to get a nice compile and and EXE file using your method above, but the file doesn't do anything. The command prompt advances to the next line so I could do something else there if I needed to, but Angband does not run. If the \lib file is renamed or deleted, I get an angband popup error to that effect. But there is no Angband window, or anything. Its like it is failing at creating the interface. So yours works ok?

            [edit]
            This problem only seems to exist on my laptop. If I copy the exe file to my desktop, then it seems to work, though slowly.

            I must have missed a config option or something. I compiled it straight out of the box, no edits or anything.

            Any thoughts?
            Last edited by APWhite; August 6, 2007, 20:38.
            St George Chiropractor
            Angband Borg Homepage

            Comment

            • ctate
              Rookie
              • Jul 2007
              • 18

              #7
              Originally posted by APWhite
              This problem only seems to exist on my laptop. If I copy the exe file to my desktop, then it seems to work, though slowly.

              I must have missed a config option or something. I compiled it straight out of the box, no edits or anything.

              Any thoughts?
              That's... very strange. It works fine for me on two different desktop machines; one running Vista and using MSVC 8, and the other running XP and using MSVC 6.

              Running slowly is because it's a debug build. If you do a release build it'll be much snappier.

              Weird. What happens if you try to run it under the VS debugger on the laptop? Maybe set a bunch of init-time breakpoints and see what is happening...

              --
              ctate

              Comment

              • APWhite
                Adept
                • Jul 2007
                • 244

                #8
                Originally posted by ctate
                Weird. What happens if you try to run it under the VS debugger on the laptop? Maybe set a bunch of init-time breakpoints and see what is happening...

                --
                ctate
                I have only used the VS environment to debug stuff. Is there a separate program to run for debugging a file? some sort of command line option or something?

                I have compiled the file in VS in debug mode (F5) and it says its "running" but it is not going anywhere. I guess I need to stick in some breakpoints and see how far it is getting. It seems like it is failing to draw the screen.

                My laptop is just a normal everyday Toshiba. Everything else on it works fine.
                St George Chiropractor
                Angband Borg Homepage

                Comment

                • ctate
                  Rookie
                  • Jul 2007
                  • 18

                  #9
                  Originally posted by APWhite
                  I have only used the VS environment to debug stuff. Is there a separate program to run for debugging a file? some sort of command line option or something?
                  The way I run random apps under VS debugging is to drag the exe file (or a shortcut) to the VS application icon. That opens up VS with that application considered the current "project." Then you just hit F5 to start execution, and off you go.

                  If you open up the source files you should be able to set breakpoints etc while running this way.

                  Good luck!

                  --
                  ctate

                  Comment

                  • APWhite
                    Adept
                    • Jul 2007
                    • 244

                    #10
                    Originally posted by ctate
                    The way I run random apps under VS debugging is to drag the exe file (or a shortcut) to the VS application icon. That opens up VS with that application considered the current "project." Then you just hit F5 to start execution, and off you go.

                    If you open up the source files you should be able to set breakpoints etc while running this way.

                    Good luck!

                    --
                    ctate
                    Thanks, I got this thing debugging now. Set up Breakpoints. It seems to be failing in main-win.c at line 1511 where a SendMessage() is called. I have commented out that line for now and it works fine. I will continue to work on it.

                    Problems may arise with the screensaver though. That routine is called in the screensaver mode. Note that the SendMessage() works fine for my laptop in version 306.

                    Thanks for your help. I was opening angband.exe as a file instead of a project and it was messing me up. If you find some time, I would like to get the full solution up so that I dont need to switch back to the cmd line in order to compile. But it is not too big of a deal;for years, I have used borlands to compile, so I am in the habit of doing so.

                    Andrew
                    St George Chiropractor
                    Angband Borg Homepage

                    Comment

                    • tigen
                      Apprentice
                      • May 2007
                      • 53

                      #11
                      For setting up Visual Studio 2005 you could try this:

                      1. Create the new solution as a "Win32 Application". In the wizard click next and check "empty project"

                      2. Source files: "add existing" all the .c and .h files from src, except only add main-win.c of the main-*. Also add the files in src/win.

                      3. Go to project properties-> configuration properties. Select configuration "all".

                      General: make sure character set is not set
                      C/C++: probably want to reduce warning level
                      Linker: probably want to change output file location to the right place (so angband will see the lib directory)
                      Linker: "Additional Dependencies" is where you would add winmm.lib if desired

                      4. Save and build.

                      Comment

                      • APWhite
                        Adept
                        • Jul 2007
                        • 244

                        #12
                        ooo very cool. That worked really well. I just had to add the .ico file to the directory where the solution was stored. Works perfectly, thanks.

                        APW
                        St George Chiropractor
                        Angband Borg Homepage

                        Comment

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