1

在 2000 年代初期,我使用这个代码库来运行一个泥浆,并通过它自学一些非常基本的编码。

我刚刚从在我之前运行服务器的管理员/编码员那里获得了一份代码库副本,我几乎可以肯定它当时会按原样编译,但现在不会。

我唯一的猜测是它与过去 15 到 20 年对 GCC 的更新有关,但我承认我是一个新手,而且我在这里很不了解。

这是我在尝试使用 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

代码库和引用的文件很大,所以我认为现在附加它们是没有意义的,但如果需要,我绝对可以提供它们。

作为记录,像“check_toughness”和“xp_compute”这样的函数肯定是在几千行代码之后在这些文件中定义的。

如有任何建议,将不胜感激,谢谢!

4

1 回答 1

3

感谢所有来提出建议的人!

rici提供了最简单的答案:

这可能是代码使用旧的特殊 gcc 语义进行内联的结果。尝试使用 --std=gnu89 进行编译(如果您使用的是 gcc)。

将其添加到 Makefile 清除了所有错误并导致编译成功。

于 2020-01-06T20:28:58.987 回答