1. Meziu210

    OP Meziu210 Newbie
    Newcomer

    Joined:
    Oct 23, 2020
    Messages:
    3
    Country:
    Italy
    So, i wanted to build srb2_3ds(can't leave link, I made the account for this post), but I'm having problems with the linking of the final .elf.
    For some reasons, the linker recognizes the same header file twice(or at least this is the issue i think I'm having).
    As you can see(the errors are hundreds, but basically all the same, and just replicas of 4 or 5 actually unique errors, that still are "double declaration" errors, so I'll just leave the last one):
    Code:
    /opt/devkitpro/devkitARM/bin/../lib/gcc/arm-none-eabi/10.2.0/../../../../arm-none-eabi/bin/ld: lua_thinkerlib.o:/home/andrea/Desktop/SRB2/srb2_3ds/source/doomtype.h:256: multiple definition of `ATTRPACK';
    i_main.o:/home/andrea/Desktop/SRB2/srb2_3ds/source/nds/../doomtype.h:256: first defined here
    collect2: error: ld returned 1 exit status
    make[1]: *** [/opt/devkitpro/devkitARM/3ds_rules:42: /home/andrea/Desktop/SRB2/srb2_3ds/srb2_3ds.elf] Error 1
    So, the "multiple definition" of ATTRPACK is on "srb2_3ds/source/doomtype.h:256", and the original declaration is on "srb2_3ds/source/nds/../doomtype.h:256", which is in fact the same exact file, at the same exact line, but the file is read twice. What could've I done wrong?
     
  2. elhobbs

    elhobbs GBAtemp Advanced Fan
    Member

    Joined:
    Jul 28, 2008
    Messages:
    864
    Country:
    United States
    What is this? https://github.com/derrekr/srb2_3ds...d62fa5fbac6105315b57ea/source/doomtype.h#L256
     
  3. Meziu210

    OP Meziu210 Newbie
    Newcomer

    Joined:
    Oct 23, 2020
    Messages:
    3
    Country:
    Italy
    That's the correct Github repo. For the line: I don't really know since this game version is very outdated and i can't find the original source of that version. All i know is that doomtype.h is used for version automation and that the struct works differently in newer versions(in fact, I'm trying to compile it to then port it to latest, since the original 3ds porters didn't commit in 2 years). Still, I don't think searching in the source would solve the problem, since i quite made clear what the error is.

    Edit:
    I managed to just remove ATTRPACK from the struct declaration(it doesn't give any compiling problems, but maybe it won't run correctly). So now I basically have 2 other error messages:
    Code:
    /opt/devkitpro/devkitARM/bin/../lib/gcc/arm-none-eabi/10.2.0/../../../../arm-none-eabi/bin/ld: lua_thinkerlib.o:/home/andrea/Desktop/SRB2/srb2_3ds/source/doomdef.h:355: multiple definition of `savegamename'; 
    i_main.o:/home/andrea/Desktop/SRB2/srb2_3ds/source/nds/../doomdef.h:355: first defined here
    Code:
    /opt/devkitpro/devkitARM/bin/../lib/gcc/arm-none-eabi/10.2.0/../../../../arm-none-eabi/bin/ld: lua_mobjlib.o:/home/andrea/Desktop/SRB2/srb2_3ds/source/doomstat.h:374: multiple definition of `ntemprecords'; 
    d_main.o:/home/andrea/Desktop/SRB2/srb2_3ds/source/doomstat.h:374: first defined here
     
    Last edited by Meziu210, Oct 24, 2020
  4. elhobbs

    elhobbs GBAtemp Advanced Fan
    Member

    Joined:
    Jul 28, 2008
    Messages:
    864
    Country:
    United States
    As a note the previous issue used ATTRPACK before it was defined. It is used as a hint to the compiler to not leave any spaces in the definition between elements.
    For the new issue savegamename is defined in the header. Change the header to be a forward declaration by adding “extern “ to the beginning here https://github.com/derrekr/srb2_3ds...9d62fa5fbac6105315b57ea/source/doomdef.h#L355
    Then copy that declaration (without extern) and add it somewhere else - the top of g_game.c seems appropriate.
     
  5. masagrator

    masagrator The developper
    Member

    Joined:
    Oct 14, 2018
    Messages:
    3,507
    Country:
    Poland
    It seems like some files are linking to the point that compiler thinks you want to add two the same things.

    Try to add at line 16 of original doomtype.h
    Code:
    #pragma once
    Maybe it will resolve issue.

    — Posts automatically merged - Please don't double post! —

    Or add it to all conflicting headers somewhere at the beginning of files.
     
  6. Meziu210

    OP Meziu210 Newbie
    Newcomer

    Joined:
    Oct 23, 2020
    Messages:
    3
    Country:
    Italy
    Didn't change anything, and I have no idea why...
    I'll continue searching for now, I'll update if i find anything
     
  7. elhobbs

    elhobbs GBAtemp Advanced Fan
    Member

    Joined:
    Jul 28, 2008
    Messages:
    864
    Country:
    United States
    See my previous post about changing multiple declarations in header files to forward declarations. It seems that previous versions of gcc allowed this with potentially unpredictable results. Newer versions mark this as an error. The fix is to change the declarations to forward declarations in the header file using the extern keyword. Then put a single declaration in only one source file.
     
Draft saved Draft deleted
Loading...

Hide similar threads Similar threads with keywords - devkitpro, Linking, problem