Search code examples
cwindows-8compiler-errorsmingwnethack

Cannot compile previously-modified Nethack using MinGW - Caching issue?


So recently, I was messing around with the source for Nethack, a rather old game. I used this guide to help me get started: Compiling - Wikihack.

To test, I first compiled the original source code. A few tweaks later, I was able to get it running without any problems. Next, I edited the source a little and added two sample monsters, based on existing monsters. The game compiled without any problems, and my test monsters were present in-game.

After that, I tried tweaking the monsters a little and recompiled. But none of my tweaks showed up, for some reason. I decided to delete everything and start from scratch, once again rebuilding the original source, no modifications done yet. And now suddenly, I'm getting errors, referencing the test monsters that are missing.

How is this possible? I double-checked that this test monster is not in the source code (and why should it be? It's the original source). My only explanation is that the compiler is caching previous data, for some reason. Emptying monst.c completely makes no difference, but removing it makes the compiler complain about a missing file.

Here is the error in question:

C:\Nethack-src\nethack-3.4.3\src>mingw32-make -f makefile.gcc install
----
NOTE: This build will include tile support.
----
creating directory o
gcc -c -mms-bitfields -I../include -I../win/win32 -g -DTILES -DMSWIN_GRAPHICS -D
_WIN32_IE=0x0400 -oo/makedefs.o ../util/makedefs.c
gcc -c -mms-bitfields -I../include -I../win/win32 -g -DTILES -DMSWIN_GRAPHICS -D
_WIN32_IE=0x0400 -DDLB  -oo/monst.o /monst.c
/monst.c:1:9: error: expected declaration specifiers or '...' before string cons
tant
     MON("test lizard", S_LIZARD,
         ^
/monst.c:1:24: error: unknown type name 'S_LIZARD'
     MON("test lizard", S_LIZARD,
                        ^
/monst.c:2:2: error: unknown type name 'LVL'
  LVL(12, 16, 0, 50, 7), (G_GENO|1),
  ^
/monst.c:2:25: error: expected declaration specifiers or '...' before '(' token
  LVL(12, 16, 0, 50, 7), (G_GENO|1),
                         ^
/monst.c:3:2: error: unknown type name 'A'
  A(ATTK(AT_CLAW, AD_PHYS, 1, 10), NO_ATTK,
  ^
/monst.c:5:2: error: unknown type name 'SIZ'
  SIZ(2600, 400, 0, MS_MUMBLE, MZ_HUGE), MR_POISON, MR_POISON,
  ^
/monst.c:5:41: error: unknown type name 'MR_POISON'
  SIZ(2600, 400, 0, MS_MUMBLE, MZ_HUGE), MR_POISON, MR_POISON,
                                         ^
/monst.c:5:52: error: unknown type name 'MR_POISON'
  SIZ(2600, 400, 0, MS_MUMBLE, MZ_HUGE), MR_POISON, MR_POISON,
                                                    ^
/monst.c:6:2: error: unknown type name 'M1_NOLIMBS'
  M1_NOLIMBS|M1_SLITHY|M1_THICK_HIDE|M1_OVIPAROUS|M1_POIS|M1_NOTAKE|
  ^
/monst.c:8:2: error: unknown type name 'M2_STRONG'
  M2_STRONG, 0, CLR_GREEN),
  ^
/monst.c:8:13: error: expected declaration specifiers or '...' before numeric co
nstant
  M2_STRONG, 0, CLR_GREEN),
             ^
/monst.c:8:16: error: unknown type name 'CLR_GREEN'
  M2_STRONG, 0, CLR_GREEN),
                ^
makefile.gcc:252: recipe for target 'o/monst.o' failed
mingw32-make: *** [o/monst.o] Error 1

C:\Nethack-src\nethack-3.4.3\src>pause
Press any key to continue . . .

How do I solve this?


Solution

  • Take a look at the build command:

    gcc -c -mms-bitfields -I../include -I../win/win32 -g
        -DTILES -DMSWIN_GRAPHICS -D _WIN32_IE=0x0400 -DDLB  -oo/monst.o /monst.c
    

    It's looking at monst.c in a completely different directory, namely /

    You probably introduced this error in the makefile after your original changes; that is the time when your code changes also stopped being effective.