How do I fix collect2 error while compiling an old MUD?

71 Views Asked by At

I'm trying to run make on an Ubuntu machine to compile a RoT MUD, but the farthest I've gotten is when I get a collect2: error: ld returned 1 exit status.

This is what comes immediately before the error in the terminal (along with a lot of other similar errors):

/usr/bin/ld: obj/wizlist.o:/home/lucas/Projects/R2b5/src/merc.h:3355: multiple definition of `bllmax'; obj/act_comm.o:/home/lucas/Projects/R2b5/src/merc.h:3355: first defined here

From what I've gathered this means that the header files have variable declarations in them, and that using static is an easy fix, however, I haven't been able to figure out where I should put that keyword in the code to fix this issue. The following is the only mention of bllmax in merc.h:

int bllmax, crbmax, crnmax, srpmax, mngmax;

Here is the program I'm trying to compile.

1

There are 1 best solutions below

3
Some programmer dude On

You need to learn the difference between declaration and definition. A declaration is telling the compiler that the symbol exists somewhere but possibly not here. A definition is telling the compiler that the symbol exists here.

The line you show (without any context) is defining the variables, which means they will be defined in each source file that includes the header file.

What it should do is to declare the variables, which can be done by making them extern:

extern int bllmax, crbmax, crnmax, srpmax, mngmax;

Then in a single source file define the variables (without extern).