Can't get this out of date DS Library to compile with current DevkitPro

95 views Asked by At

I wan't to try and develop a little DS game as a hobby project. I precise that it is also a way for me to reuse C/C++ after several years, and the comeback is a bit difficult. Sorry in advance if I miss obvious stuff, I forgot a lot of what I used to know.

I found this library: https://github.com/CTurt/dsgmLib. Problem: I tried to check the example "Collision", and I can't get it to compile. Currently, what i am seeing is this:

 make
project.c
In file included from C:/devkitPro/dsgmLib/examples/Collision/source/project.c:3:
C:/devkitPro/dsgmLib/include/DSGM_projectHelper.h: In function 'DSGM_BackgroundIsNitro':
C:/devkitPro/dsgmLib/include/DSGM_projectHelper.h:67:16: warning: array subscript background is outside array bounds of 'DSGM_Background[0]' [-Warray-bounds]
   67 |         return DSGM_BackgroundIsNitroFull(&DSGM_Backgrounds[background]);
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/devkitPro/dsgmLib/examples/Collision/source/project.c:12:17: note: while referencing 'DSGM_Backgrounds'
   12 | DSGM_Background DSGM_Backgrounds[DSGM_BACKGROUND_COUNT] = {
      |                 ^~~~~~~~~~~~~~~~
C:/devkitPro/dsgmLib/include/DSGM_projectHelper.h: In function 'DSGM_LoadBackground':
C:/devkitPro/dsgmLib/include/DSGM_projectHelper.h:72:28: warning: array subscript background is outside array bounds of 'DSGM_Background[0]' [-Warray-bounds]
   72 |         layer.background = &DSGM_Backgrounds[background];
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/devkitPro/dsgmLib/examples/Collision/source/project.c:12:17: note: while referencing 'DSGM_Backgrounds'
   12 | DSGM_Background DSGM_Backgrounds[DSGM_BACKGROUND_COUNT] = {
      |                 ^~~~~~~~~~~~~~~~
linking Collision.elf
c:/devkitpro/devkitarm/bin/../lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld.exe: C:/devkitPro/dsgmLib/lib\libdsgm.a(DSGM.o):C:/Users/gagef/Documents/git/dsgmLib/include/DSGM_object.h:75: multiple definition of `DSGM_invalidObjectInstance'; project.o:C:/devkitPro/dsgmLib/examples/Collision/source/project.c:9: first defined here
c:/devkitpro/devkitarm/bin/../lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld.exe: C:/devkitPro/dsgmLib/lib\libdsgm.a(DSGM_background.o):C:/Users/gagef/Documents/git/dsgmLib/include/DSGM_object.h:75: multiple definition of `DSGM_invalidObjectInstance'; project.o:C:/devkitPro/dsgmLib/examples/Collision/source/project.c:9: first defined here
c:/devkitpro/devkitarm/bin/../lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld.exe: C:/devkitPro/dsgmLib/lib\libdsgm.a(DSGM_file.o):C:/Users/gagef/Documents/git/dsgmLib/include/DSGM_object.h:75: multiple definition of `DSGM_invalidObjectInstance'; project.o:C:/devkitPro/dsgmLib/examples/Collision/source/project.c:9: first defined here
c:/devkitpro/devkitarm/bin/../lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld.exe: C:/devkitPro/dsgmLib/lib\libdsgm.a(DSGM_input.o):C:/Users/gagef/Documents/git/dsgmLib/include/DSGM_object.h:75: multiple definition of `DSGM_invalidObjectInstance'; project.o:C:/devkitPro/dsgmLib/examples/Collision/source/project.c:9: first defined here
c:/devkitpro/devkitarm/bin/../lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld.exe: C:/devkitPro/dsgmLib/lib\libdsgm.a(DSGM_largeBackground.o):C:/Users/gagef/Documents/git/dsgmLib/include/DSGM_object.h:75: multiple definition of `DSGM_invalidObjectInstance'; project.o:C:/devkitPro/dsgmLib/examples/Collision/source/project.c:9: first defined here
c:/devkitpro/devkitarm/bin/../lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld.exe: C:/devkitPro/dsgmLib/lib\libdsgm.a(DSGM_malloc.o):C:/Users/gagef/Documents/git/dsgmLib/include/DSGM_object.h:75: multiple definition of `DSGM_invalidObjectInstance'; project.o:C:/devkitPro/dsgmLib/examples/Collision/source/project.c:9: first defined here
c:/devkitpro/devkitarm/bin/../lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld.exe: C:/devkitPro/dsgmLib/lib\libdsgm.a(DSGM_object.o):C:/Users/gagef/Documents/git/dsgmLib/include/DSGM_object.h:75: multiple definition of `DSGM_invalidObjectInstance'; project.o:C:/devkitPro/dsgmLib/examples/Collision/source/project.c:9: first defined here
c:/devkitpro/devkitarm/bin/../lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld.exe: C:/devkitPro/dsgmLib/lib\libdsgm.a(DSGM_palette.o):C:/Users/gagef/Documents/git/dsgmLib/include/DSGM_object.h:75: multiple definition of `DSGM_invalidObjectInstance'; project.o:C:/devkitPro/dsgmLib/examples/Collision/source/project.c:9: first defined here
c:/devkitpro/devkitarm/bin/../lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld.exe: C:/devkitPro/dsgmLib/lib\libdsgm.a(DSGM_room.o):C:/Users/gagef/Documents/git/dsgmLib/include/DSGM_object.h:75: multiple definition of `DSGM_invalidObjectInstance'; project.o:C:/devkitPro/dsgmLib/examples/Collision/source/project.c:9: first defined here
c:/devkitpro/devkitarm/bin/../lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld.exe: C:/devkitPro/dsgmLib/lib\libdsgm.a(DSGM_sound.o):C:/Users/gagef/Documents/git/dsgmLib/include/DSGM_object.h:75: multiple definition of `DSGM_invalidObjectInstance'; project.o:C:/devkitPro/dsgmLib/examples/Collision/source/project.c:9: first defined here
c:/devkitpro/devkitarm/bin/../lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld.exe: C:/devkitPro/dsgmLib/lib\libdsgm.a(DSGM_sprite.o):C:/Users/gagef/Documents/git/dsgmLib/include/DSGM_object.h:75: multiple definition of `DSGM_invalidObjectInstance'; project.o:C:/devkitPro/dsgmLib/examples/Collision/source/project.c:9: first defined here
c:/devkitpro/devkitarm/bin/../lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld.exe: C:/devkitPro/dsgmLib/lib\libdsgm.a(DSGM_text.o):C:/Users/gagef/Documents/git/dsgmLib/include/DSGM_object.h:75: multiple definition of `DSGM_invalidObjectInstance'; project.o:C:/devkitPro/dsgmLib/examples/Collision/source/project.c:9: first defined here
c:/devkitpro/devkitarm/bin/../lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld.exe: C:/devkitPro/dsgmLib/lib\libdsgm.a(DGM_wireless.o):C:/Users/gagef/Documents/git/dsgmLib/include/DSGM_object.h:75: multiple definition of `DSGM_invalidObjectInstance'; project.o:C:/devkitPro/dsgmLib/examples/Collision/source/project.c:9: first defined here
c:/devkitpro/devkitarm/bin/../lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld.exe: C:/devkitPro/dsgmLib/lib\libdsgm.a(DSGM_drawable.o):C:/Users/gagef/Documents/git/dsgmLib/include/DSGM_object.h:75: multiple definition of `DSGM_invalidObjectInstance'; project.o:C:/devkitPro/dsgmLib/examples/Collision/source/project.c:9: first defined here
c:/devkitpro/devkitarm/bin/../lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld.exe: C:/devkitPro/dsgmLib/lib\libdsgm.a(DSGM_misc.o):C:/Users/gagef/Documents/git/dsgmLib/include/DSGM_object.h:75: multiple definition of `DSGM_invalidObjectInstance'; project.o:C:/devkitPro/dsgmLib/examples/Collision/source/project.c:9: first defined here
collect2.exe: error: ld returned 1 exit status
make[1]: *** [/opt/devkitpro/devkitARM/ds_rules:54: /c/devkitPro/dsgmLib/examples/Collision/Collision.elf] Error 1
make: *** [/opt/devkitpro/dsgmLib/DSGM_Makefile:124: build] Error 2

The problem seems to come from the file DSGM_object.h. Here is the beginning of the file:

#pragma once

#define DSGM_NO_EVENT NULL

#define DSGM_DEFAULT_BITSHIFT 8

#define DSGM_ValidateObjectInstance(objectInstance); if(objectInstance == DSGM_invalidObjectInstance) {\
    DSGM_invalidObjectInstance = NULL;\
    continue;\
}

struct DSGM_objectInstance;

// ... Other stuff 

#include "DSGM_room.h"

extern void *me;
DSGM_ObjectInstance *DSGM_invalidObjectInstance;

// ... More stuff

DSGM_invalidObjectInstance is then referenced in DSGM_object.c, and knowhere else (I checked with VisualStudioCode). Nothing on what I read about this error allowed me to understand why this is not compiling.

0

There are 0 answers