Home Artists Posts Import Register

Content

Been trying to get a simple "Hello World" example running in Retroquad's console.

So far I seem to have properly set up the libraries and the build options, but there are countless errors showing up when linking the code. Example:

C:/Dev/Tools/TDM-GCC-32/bin/../lib/gcc/mingw32/10.3.0/../../../../mingw32/bin/ld.exe: cb_release_32\bsp_skyb.o (symbol from plugin):(.text+0x0): multiple definition of `in_keys'; cb_release_32\bsp_sky.o (symbol from plugin):(.text+0x0): first defined here

However, neither of those source files (for skyboxes and scrolling skies) uses in_keys. So, the first hint is that the problem lies in the headers included by quakedef.h.

Searching for in_keys, we can see that it's an enum from keys.h:

enum
{
...
} in_keys;

There is an issue with this because this enumeration is not just being declared, it is also being defined. This means that there's likely a copy of in_keys for each source file in the whole engine. While the linker never had an issue with this before, I guess that including support for OpenMP parallelization makes the linker operate in a more strict way.

To fix that, I've changed the enum in the keys.h to this:

typedef enum // for the given type,
{
...
} in_enumkeys_t; // ... creates a new alias name
extern in_enumkeys_t in_keys; // declare a variable of the type given by the alias

And added this to the beginning of keys.c:

in_enumkeys_t in_keys; // define the variable

And now this error message is gone, because the declarations from all source files points to a definition that is compiled only once.

There are tons more of similar linking errors that needs to be fixed like this in the code. Likely hundreds, but hopefully not thousands. This is because the original Quake code did not use the extern keyword for the variables in the headers. In the new code I've written myself I always declare header variables properly, but there's still a lot of old code in the engine.

After fixing all of those errors, I should be able to make the "hello world" test work. Fingers crossed.

Comments

No comments found for this post.