Compiling homebrew with make throws error from linker

Discussion in '3DS - Homebrew Development and Emulators' started by JackMacWindows, Jan 16, 2016.

  1. JackMacWindows
    OP

    JackMacWindows Member

    Newcomer
    41
    20
    Jan 16, 2016
    United States
    I have been working on porting a game I made with a friend to the 3DS. Now I am debug-compiling the port to see how many errors there are. It took me a while to find a makefile, but now when I run make, it throws the error .../armv6k/fpu/3dsx_crt0.o: In function 'ClrLoop'(.crt0+0x8c): undefined reference to 'main'. Here is the makefile:
    Makefile

    I have OS X, if that matters, with Xcode and devkitPro installed to /opt/devkitPro. What is wrong, and how is it fixed? (If you need the source code to identify the problem, please tell me.)
     
    Last edited by JackMacWindows, Jan 17, 2016
  2. JackMacWindows
    OP

    JackMacWindows Member

    Newcomer
    41
    20
    Jan 16, 2016
    United States
    The 3dsx_crt0.o comes from the 3dsx_crto.s file that is with the standard libctru download. I also tried this on another Mac with no success. I will try Windows...
     
  3. Rinnegatamante

    Rinnegatamante GBAtemp Psycho!

    Member
    3,127
    3,271
    Nov 24, 2014
    Italy
    Bologna
    Navigate to \devkitPro\devkitARM\arm-none-eabi\lib and launch "make CRT=3dsx" with terminal.
     
  4. JackMacWindows
    OP

    JackMacWindows Member

    Newcomer
    41
    20
    Jan 16, 2016
    United States
    It seems like something happened, but I still get the same error.
    Output
     
    Last edited by JackMacWindows, Jan 23, 2016
  5. Slashcash

    Slashcash GBAtemp Fan

    Member
    334
    461
    Oct 15, 2015
    Italy
    Just a random thought: are the c/cpp files in a folder called source? If not: that's the reason
     
    Last edited by Slashcash, Jan 23, 2016
  6. MasterFeizz

    MasterFeizz GBAtemp Advanced Fan

    Member
    888
    833
    Oct 15, 2015
    United States
    Its not a problem with 3dsx_crt0.o, its a problem with your sources. You haven't defined the main() function, or you are not compiling the file in which its defined.
     
  7. JackMacWindows
    OP

    JackMacWindows Member

    Newcomer
    41
    20
    Jan 16, 2016
    United States
    int main(int argc, char** argv[]) {

    Right after the function definitions. Is that the wrong type for argv? It also didn't work without the arguments.

    EDIT: I tried somebody else's (int argc, char **argv), but it didn't work either.
     
    Last edited by JackMacWindows, Jan 23, 2016
  8. MasterFeizz

    MasterFeizz GBAtemp Advanced Fan

    Member
    888
    833
    Oct 15, 2015
    United States
    char** argv[] is wrong.
    It should be one of the following
    Code:
    char** argv
    char* argv[]
    or main could also take no argument
    Code:
    int main(void)
    
     
  9. JackMacWindows
    OP

    JackMacWindows Member

    Newcomer
    41
    20
    Jan 16, 2016
    United States
    Still not right, error is still occurring.

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

    No, they are not in a source folder. And it worked. Thanks!
     
  10. Slashcash

    Slashcash GBAtemp Fan

    Member
    334
    461
    Oct 15, 2015
    Italy
    Take a look at this line of the Makefile:

    Code:
    SOURCES := source
    The compiler will scan the folder listed after the := symbol for source files. You could add multiple folders by adding paths separated by a space
     
  11. Zer0Entry

    Zer0Entry Newbie

    Newcomer
    1
    0
    Jan 23, 2017
    United States
    What do you mean by "are the c/cpp files in a folder called source?" and how would I do that?