1

I used this codebase to run a mud in the early 2000s, and through that, to teach myself some very elementary coding.

I just got a copy of the codebase from the administrator/coder who ran the server before me, and I'm just about certain that it would compile as-is back then, but now it won't.

My only guess is that it has something to do with updates to GCC in the last 15-20 years, but I'm admittedly a novice and pretty out of my depth here.

This is the error I get after about a hundred pages of warnings when I try to compile it using make:

[18:24:54] finger.c ...
In file included from finger.c:10:0:
../src/include/merc.h:5149:13: warning: inline function ‘check_toughness’ declared but never defined
 inline int  check_toughness args( ( CD *ch, CD *victim, int dam));
             ^~~~~~~~~~~~~~~
[18:24:54] Linking Executable ...
obj/fight.o: In function `group_gain':
tbw/reloaded/src/fight.c:5514: undefined reference to `xp_compute'
tbw/reloaded/src/fight.c:5516: undefined reference to `xp_compute'
tbw/reloaded/src/fight.c:5518: undefined reference to `xp_compute'
obj/fight.o: In function `one_hit':
tbw/reloaded/src/fight.c:2457: undefined reference to `check_toughness'
obj/mage.o: In function `do_chant':
tbw/reloaded/src/mage.c:345: undefined reference to `check_toughness'
tbw/reloaded/src/mage.c:361: undefined reference to `check_toughness'
tbw/reloaded/src/mage.c:377: undefined reference to `check_toughness'
tbw/reloaded/src/mage.c:393: undefined reference to `check_toughness'
obj/mage.o:tbw/reloaded/src/mage.c:409: more undefined references to `check_toughness' follow
obj/update.o: In function `mobile_update':
tbw/reloaded/src/update.c:756: undefined reference to `werewolf_regen'
obj/powerl.o: In function `do_planarstorm':
tbw/reloaded/src/powerl.c:680: undefined reference to `check_toughness'
collect2: error: ld returned 1 exit status
Makefile:27: recipe for target '../src/reloaded' failed
make: *** [../src/reloaded] Error 1

The codebase and the referenced files are huge, so I figured it wouldn't make sense to attach them just yet, but if required I can definitely provide them.

For the record, those functions like "check_toughness" and "xp_compute" are definitely defined within those files after a few thousand LOC.

Would appreciate any suggestions, thank you!

Barmar
  • 741,623
  • 53
  • 500
  • 612
vdotcodes
  • 101
  • 5
  • 2
    An inline function should be defined in the `.h` file. – Barmar Jan 06 '20 at 19:25
  • 2
    Did you set the C language standard to something like `C99`? – Arush Agarampur Jan 06 '20 at 19:25
  • 2
    If they are defined after, they will not be found during the build process. They should either have been declared above the `main` function in the `.C` file, or have forward declarations in the header files. – Arush Agarampur Jan 06 '20 at 19:28
  • 1
    You should just remove the `inline` keyword. If you want a function to be inlined, as mentioned above, then the body of the function needs to appear in the header file. You could do that but the simplest thing to do is take out the `inline` so the compiler treats it like any other function. You also have to figure out where those functions ARE defined because the compiler can't seem to find them. Maybe they're `static` or something? – MadScientist Jan 06 '20 at 19:53
  • 5
    That is probably the result of the code using the old idiosyncratic gcc semantics for `inline`. Try compiling with `--std=gnu89` (if you are using gcc). – rici Jan 06 '20 at 19:55
  • @rici Thank you! That actually cleared the errors and resulted in a successful compile. – vdotcodes Jan 06 '20 at 20:17

1 Answers1

3

Thank you to everyone who came in with suggestions!

The simplest answer was provided by rici:

That is probably the result of the code using the old idiosyncratic gcc semantics for inline. Try compiling with --std=gnu89 (if you are using gcc).

Adding that to the Makefile cleared up all the errors and resulted in a successful compile.

vdotcodes
  • 101
  • 5