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 > devkitARM/devkitadv & Linux crt0.o compile error

#61456 - Savage - Sun Nov 20, 2005 1:53 pm

Hi all, I've been playing with GBA dev on Windows, and am trying to move my operation over to Linux, I've tried both devkitARM and devkitadv, added the path for either and attempted to compile with the following output:

Code:
[savage@savnet-wrk-03 sokoban]$ arm-elf-gcc -o sokoban.elf main.c
/opt/devkitARM/bin/../lib/gcc/arm-elf/4.0.2/../../../../arm-elf/bin/ld: crt0.o: No such file: No such file or directory
collect2: ld returned 1 exit status


Does anyone have any suggestions as to what's causing this? or more importantly, how to fix it :D

Cheers, Savage

#61460 - pepsiman - Sun Nov 20, 2005 2:50 pm

Savage wrote:
Does anyone have any suggestions as to what's causing this? or more importantly, how to fix it :D

You're not using the template.

#61463 - Quirky - Sun Nov 20, 2005 3:24 pm

Not sure what template pepsiman means, but try adding -specs=gba.specs:

Code:
 arm-elf-gcc -o sokoban.elf main.c -specs=gba.specs

#61478 - Savage - Sun Nov 20, 2005 5:43 pm

Thanks guys, that's got it compiling without error, next problem :P

The sokoban.elf file produced is 57Kb smaller than the .elf file produced by the Windows version, and after objcopy, just goes black in the emulator...

Thanks, Savage

#61482 - wintermute - Sun Nov 20, 2005 6:52 pm

PM me the source, assuming you don't mind, & I'll take a look at what's going on.

#61498 - Savage - Sun Nov 20, 2005 11:04 pm

I've just this minute put the source up on me site:

http://www.savagereactor.co.uk/?page=computing/gba/sokoban/default.php

It's not a problem with the source (I don't think), it compiles and works fine on Windows, but I'm trying to move over to Linux as it's my preferred OS, I think it's a problem with devkitARM on Linux, but I've only been into GBA programming for the past week.

Thanks, Savage

#61519 - wintermute - Mon Nov 21, 2005 4:00 am

You're not kidding about "I strongly recommend against using it as any kind of reference" :P

Anyway, I've just tried the source on both linux and windows devkitARM and it seems to be working fine for me. The ELF from both systems appears to be identical so I'm not entirely sure what's going on on your system.

The command line I used was arm-elf-gcc -mthumb -mthumb-interwork -specs=gba.specs main.c -o sokoban.elf

the -mthumb flag is generally recommended since it produces smaller code overall although ARM code can be much faster in the right circumstances. The data bus to the GBA cart is 16bit which slows ARM code down due to the need to make two fetches for each instruction.

The important part of the command line is the -mthumb-interwork switch which allows thumb and arm code to call each other, switching state as appropriate. This is mainly necessary for certain parts of the crt0 startup code and interrupt code where ARM code *must* be used.

There are some issues with the code, related more to good coding practices which make this fairly unsuitable to use as a basis for anything else. I assume you've followed some of the horrendous "tutorials" that plague the homebrew programming scene.

  • C files should *never* be #included from other C files.
  • .h files should never contain code or data, with the exception of static inline functions.


An extremely good set of tutorials can be found at Cearn Space

#61542 - Savage - Mon Nov 21, 2005 12:42 pm

Cool, that's got it working, thanks :D

As for the coding, yes I'd agree it's awful, it was my very first attempt at a C program (excluding a hello world app 3 months ago) lol.

I'd blame myself more than the tutorials I followed, I started with a very basic how to draw a PCX, borrowed those gba_*.h files from Tank Advance, and dived in head first. I'm a self-taught "programmer", if you can call me that, so I've never really been exposed to any good practises, but it's one of my goals for this GBA mission.

I wasn't going to put the source on the site initially, it's a little embarrassing, but we all have to start somewhere :P

*edit* coming to think of it, do you know any sites that do document good programming practices?

Thanks for you're help

Savage