• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Pokeemerald-expansion] How to fix undefined references

5
Posts
16
Days
    • Seen May 7, 2024
    I'm new to ROM hacking and I am having an issue when compiling the files. It gives me an error talking about undefined references. I tried to look at the files but VSCode said that the file was in binary or an unsupported language. When I do try to compile the files, it does not tell me that the file was deleted like other errors, but I cannot find the compiled file. What should I do?
     

    Attachments

    • [Pokeemerald-expansion] How to fix undefined references
      romhelp.JPG
      283 KB · Views: 5
    • [Pokeemerald-expansion] How to fix undefined references
      romhelp1.JPG
      53.7 KB · Views: 5
    • [Pokeemerald-expansion] How to fix undefined references
      romhelp2.JPG
      993.8 KB · Views: 5
    451
    Posts
    6
    Years
    • Seen yesterday
    I'm new to ROM hacking and I am having an issue when compiling the files. It gives me an error talking about undefined references. I tried to look at the files but VSCode said that the file was in binary or an unsupported language. When I do try to compile the files, it does not tell me that the file was deleted like other errors, but I cannot find the compiled file. What should I do?
    Undefined reference means that you have referenced some symbol like function or variable name, but it isn't defined at the point where you're using it.
    For example your errors are saying that you're referencing a symbol called "gItemsInfo" in various places even though such symbol is not known to the compiler at those places. To fix the issue you either need to make sure that the symbol is defined or remove the reference to it.

    This specific error is a bit odd since gItemsInfo is normally used in those places in pokeemerald-expansion and it's defined in the repo. Perhaps you could explain what you did with the repo to get to this point.

    Also you generally don't need to care about compiled binary files. Instead you should look at the source files that the binaries are created from.
     
    Last edited:
    5
    Posts
    16
    Days
    • Seen May 7, 2024
    Undefined reference means that you have referenced some symbol like function or variable name, but it isn't defined at the point where you're using it.
    For example your errors are saying that you're referencing a symbol called "gItemsInfo" in various places even though such symbol is not known to the compiler at those places. To fix the issue you either need to make sure that the symbol is defined or remove the reference to it.

    This specific error is a bit odd since gItemsInfo is normally used in those places in pokeemerald-expansion and it's defined in the repo. Perhaps you could explain what you did with the repo to get to this point.

    Also you generally don't need to care about compiled binary files. Instead you should look at the source files that the binaries are created from.
    I have not done anything to the repo. I did add more TMs, but I modified other files to add them. Could that be the reason I'm getting the error.
     
    451
    Posts
    6
    Years
    • Seen yesterday
    I have not done anything to the repo. I did add more TMs, but I modified other files to add them. Could that be the reason I'm getting the error.
    Were you able to compile the project before making those changes? If you were then your changes are at fault, otherwise the problem could be that you didn't install the project correctly.
    Since you edited items, it seems pretty likely that you made some kind of mistake in src/data/items.h which is causing gItemsInfo to not be defined.
     
    5
    Posts
    16
    Days
    • Seen May 7, 2024
    Were you able to compile the project before making those changes? If you were then your changes are at fault, otherwise the problem could be that you didn't install the project correctly.
    Since you edited items, it seems pretty likely that you made some kind of mistake in src/data/items.h which is causing gItemsInfo to not be defined.
    Here is the repo with my changes. I don't see any issues, but I am inexperienced. Please look over it when you get the chance. https://github.com/Houndoom10/Error-testing/blob/main/items.h
     
    451
    Posts
    6
    Years
    • Seen yesterday
    Here is the repo with my changes. I don't see any issues, but I am inexperienced. Please look over it when you get the chance. https://github.com/Houndoom10/Error-testing/blob/main/items.h
    Thanks for providing the file, but it would be a lot easier to use if you shared your whole repo.
    You've added quite a few TMs and made a lot of changes to the file. It's generally a good idea to compile the project as you make changes so that when an error occurs, you have fewer changes making it easier to tell which change caused the error.

    When compiling the project with your file the very first error message was:
    Code:
    <stdin>/src/item.c:11611: error: unknown character U+2014
    I searched for that character in src/data/items.h and found that line 1290 uses the unicode character — instead of -.

    After replacing that character I got the error:
    Code:
    src/data/items.h:11932:6: error: 'ITEM_TM101' undeclared here (not in a function)
    11932 |     [ITEM_TM101] =
    So I had to define the new TM constants in include/constants/items.h, which you've presumably already done. This is why it would've been nice if you posted your whole repo and not just that one file.

    After that I then encountered the error:
    Code:
    src/data/items.h:15582:103: error: excess elements in array initializer [-Werror]
    15582 |         .name = _("POKEBLOCK Case"),
    Which happens because the name "POKEBLOCK Case" is too long. By default the name is "{POKEBLOCK} Case", where the {POKEBLOCK} gets replaced with a specific character sequence that is shorter than "POKEBLOCK". I fixed the error by replacing instances of "POKEBLOCK" with "{POKEBLOCK}".

    After that src/item.c was able to compile correctly but I still encountered one more error:
    Code:
    src/pokemon.c:748:14: error: size of array 'PokemonSubstruct0_heldItem_TooSmall' is negative
      748 | STATIC_ASSERT(ITEMS_COUNT < (1 << 10), PokemonSubstruct0_heldItem_TooSmall);
    Because there are now more items than what can be stored inside the pokemon structure. You should increase the amount of bits dedicated to a pokemon's held item if you didn't already.
     
    5
    Posts
    16
    Days
    • Seen May 7, 2024
    Thanks for providing the file, but it would be a lot easier to use if you shared your whole repo.
    You've added quite a few TMs and made a lot of changes to the file. It's generally a good idea to compile the project as you make changes so that when an error occurs, you have fewer changes making it easier to tell which change caused the error.

    When compiling the project with your file the very first error message was:
    Code:
    <stdin>/src/item.c:11611: error: unknown character U+2014
    I searched for that character in src/data/items.h and found that line 1290 uses the unicode character — instead of -.

    After replacing that character I got the error:
    Code:
    src/data/items.h:11932:6: error: 'ITEM_TM101' undeclared here (not in a function)
    11932 |     [ITEM_TM101] =
    So I had to define the new TM constants in include/constants/items.h, which you've presumably already done. This is why it would've been nice if you posted your whole repo and not just that one file.

    After that I then encountered the error:
    Code:
    src/data/items.h:15582:103: error: excess elements in array initializer [-Werror]
    15582 |         .name = _("POKEBLOCK Case"),
    Which happens because the name "POKEBLOCK Case" is too long. By default the name is "{POKEBLOCK} Case", where the {POKEBLOCK} gets replaced with a specific character sequence that is shorter than "POKEBLOCK". I fixed the error by replacing instances of "POKEBLOCK" with "{POKEBLOCK}".

    After that src/item.c was able to compile correctly but I still encountered one more error:
    Code:
    src/pokemon.c:748:14: error: size of array 'PokemonSubstruct0_heldItem_TooSmall' is negative
      748 | STATIC_ASSERT(ITEMS_COUNT < (1 << 10), PokemonSubstruct0_heldItem_TooSmall);
    Because there are now more items than what can be stored inside the pokemon structure. You should increase the amount of bits dedicated to a pokemon's held item if you didn't already.
    I apologize for the delayed response, I was trying to figure out how to get all my files on the remote repo as I am new to this stuff. I did change the held item bits. I just wanted to let you know I fixed the errors you pointed out. I have the repo link: https://github.com/Houndoom10/full-error-test
    Please look over it when you get the chance.
    Before I had this issue, I had 2 issues, one with character limits and one about Ogerpon's forms and info, which both were fixed. Additionally, before that issue, it would compile because I was working on an older version of the expansion, I waited until they added the new Pokémon with the Indigo Disc.
    Also, if you check the starter choices and they are Hydrapple, Raging Bolt, and Gouging Fire, I wanted it like that to know that the modified version.
     
    451
    Posts
    6
    Years
    • Seen yesterday
    I apologize for the delayed response, I was trying to figure out how to get all my files on the remote repo as I am new to this stuff. I did change the held item bits. I just wanted to let you know I fixed the errors you pointed out. I have the repo link: https://github.com/Houndoom10/full-error-test
    Please look over it when you get the chance.
    Before I had this issue, I had 2 issues, one with character limits and one about Ogerpon's forms and info, which both were fixed. Additionally, before that issue, it would compile because I was working on an older version of the expansion, I waited until they added the new Pokémon with the Indigo Disc.
    Also, if you check the starter choices and they are Hydrapple, Raging Bolt, and Gouging Fire, I wanted it like that to know that the modified version.
    So to clarify, the above changes did not fix the initial issue. This is because you have removed the include for the src/data/items.h file and it's no longer even getting compiled, which makes everything in the file undefined.
     
    5
    Posts
    16
    Days
    • Seen May 7, 2024
    So to clarify, the above changes did not fix the initial issue. This is because you have removed the include for the src/data/items.h file and it's no longer even getting compiled, which makes everything in the file undefined.
    I appreciate your help. The project is now able to compile. I remember why I erased the statement. I was previously getting an error message about that specific statement. So, I tried erasing and compiling it, which eliminated the error.
     
    Back
    Top