gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > Simple Hello World - wont compile.

#104058 - JesterDev - Tue Sep 26, 2006 7:45 am

I'm using http://www.dsprogramming101.com/ tutorials, and I cannot get my code to compile but the Hello world example from the site compiles just fine..
Not sure what I'm doing wrong..

My code:
Code:

// Hello World For the Nintendo DS

// Inlcudes
#include <nds.h>
#include <nds/arm9/console.h> // basic print functionality
#include <stdio.h>


int main(void) {

        videoSetMode(0); // not using the main (touch) screen
        videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE); // sub bg 0 will be used to print text
        vramSetBankC(VRAM_C_SUB_BG);
        SUB_BG0_CR = BG_MAP_BASE(31);
        BG_PALETTE_SUB[255] = RGB15(31,31,31); // BG Black / Text White

        // consoleInit() is alot more flexible and gets us up and working quickly
        consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(31), (u16*)SCREEN_BASE_BLOCK_SUB(0), 16);
        iprintf("Hello World!");

        while(1) {
            swiWaitForVBlank(); // wait for the next screen refresh
    } // end of while loop
        return 0;
} // end main


The the error I'm getting:
linking Work.elf
c:/devkitpro/devkitarm/bin/../lib/gcc/arm-eabi/4.1.1/../../../../arm-eabi/lib/th
umb/ds_arm9_crt0.o: In function `CIDLoop':
ds_arm9_crt0.s:(.init+0x218): undefined reference to `main'
collect2: ld returned 1 exit status
make[1]: *** [/c/devkitPro/Work/Work.elf] Error 1
make: *** [build] Error 2

Any ideas? I've compared my code with the downloaded example, and as far as I can see they are both the same (save for comments).

#104063 - JesterDev - Tue Sep 26, 2006 8:21 am

Never mind. I wasn't told that I needed to copy the entire arm9 dir into my programs source dir. : /

#104106 - thegamefreak0134 - Tue Sep 26, 2006 4:56 pm

You shouldnt need to. Try setting a path variable in the makefile (or batch file) to the directory where they are kept. (This assumes you havent tried this already...)

-gamefreak
_________________
What if the hokey-pokey really is what it's all about?

[url=http:/www.darknovagames.com/index.php?action=recruit&clanid=1]Support Zeta on DarkNova![/url]