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.

DS development > Including data into projects

#89485 - spencer723 - Sun Jun 25, 2006 3:08 am

Hi, I'm sort of new to using tile maps and I was trying to compile and got errors saying the #includes didn't exist. I haven't exactly figured out how to include my .bin files into my project. I have myBG.bin, myBGpal.bin and myBGmap.bin and I was wondering how to include these into my project...does it have to do with the Makefile? This is my Makefile as of now:

Code:

# Makefile for framebuffer_demo1.nds
# chris.double@double.co.nz
NDSLIB_INCLUDE=$(DEVKITPRO)/libnds/include
NDSLIB_LIB=$(DEVKITPRO)/libnds/lib

all: drds_BETA.nds.gba

arm7_main.o: arm7_main.cpp
   arm-elf-g++ -g -Wall -O2 -mcpu=arm7tdmi -mtune=arm7tdmi -fomit-frame-pointer -ffast-math -mthumb-interwork -I$(NDSLIB_INCLUDE) -DARM7 -c arm7_main.cpp -oarm7_main.o

arm7.elf: arm7_main.o
   arm-elf-g++ -g -mthumb-interwork -mno-fpu -specs=ds_arm7.specs arm7_main.o -L$(NDSLIB_LIB) -lnds7 -oarm7.elf

arm7.bin: arm7.elf
   arm-elf-objcopy -O binary arm7.elf arm7.bin

arm9_main.o: arm9_main.cpp
   arm-elf-g++ -g -Wall -O2 -mcpu=arm9tdmi -mtune=arm9tdmi -fomit-frame-pointer -ffast-math -mthumb-interwork -I$(NDSLIB_INCLUDE) -DARM9 -c arm9_main.cpp -oarm9_main.o

arm9.elf: arm9_main.o
   arm-elf-g++ -g -mthumb-interwork -mno-fpu -specs=ds_arm9.specs arm9_main.o -L$(NDSLIB_LIB) -lnds9 -o arm9.elf

arm9.bin: arm9.elf
   arm-elf-objcopy -O binary arm9.elf arm9.bin

drds_BETA.nds: arm7.bin arm9.bin
   ndstool -c drds_BETA.nds -9 arm9.bin -7 arm7.bin

drds_BETA.nds.gba: drds_BETA.nds
   dsbuild drds_BETA.nds -o drds_BETA.nds.gba

clean:
   rm -f *.bin
   rm -f *.elf
   rm -f *.o
   rm -f *~


I'll appreciate any help :)

#89514 - parrot_ - Sun Jun 25, 2006 9:08 am

If your includes are in a directory you have to add an -I[PATHTOINCLUDES], also if you are using r19a, change arm-elf-g++ to arm-eabi-g++ (only do that if you are using r19a)
_________________
Squak! etc.
My Blog

#89556 - spencer723 - Sun Jun 25, 2006 1:54 pm

Right now my 3 files are still .bin's. Should they be .h files? Also, what line would I add the '-I' to in the Makefile?

#89561 - psycorpse - Sun Jun 25, 2006 3:14 pm

You should have your .bin files in a folder called data. In your makefile you should add something like the following:

DATA := data

BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))

export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)

#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#---------------------------------------------------------------------------------
%.bin.o : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)



I am not 100% sure this will work as you are using chris's makefile. You could move to using the makefile in the libnds examples. Anyways you will also need to a #include "filename_bin.h" (myBGmap_bin.h)

hope this helps.

#89570 - spencer723 - Sun Jun 25, 2006 4:05 pm

I tried using the libnds example and the compiler gave me an error about a CIDLoop.

#89707 - spencer723 - Mon Jun 26, 2006 1:03 pm

I got it to work, but instead of using the Makfile I made a batch file that will convert it with gfx2gba then it runs bin2h. The only problem there is I actually have to go into the .h files and change everything myself and add how long each one is.

#89740 - wintermute - Mon Jun 26, 2006 3:06 pm

spencer723 wrote:
I tried using the libnds example and the compiler gave me an error about a CIDLoop.


The precise error message would help in diagnosing your problem.

You should also update to r19a and stop using examples which don't use a variant of the standard devkitPro makefiles.
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog

#89834 - spencer723 - Mon Jun 26, 2006 9:28 pm

I've already updated to r19a. The specific error I'm getting is below:

Code:

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/DSDev/Examples/Examples.elf] Error 1
make: *** [build] Error 2


This is coming from the Makfile that comes with the examples in devkitARM.

#93217 - spencer723 - Mon Jul 17, 2006 9:14 pm

bump

#93252 - josath - Tue Jul 18, 2006 2:15 am

dumb question: Do you have main defined in one of the .c or .cpp files in your source directory?

#93265 - wintermute - Tue Jul 18, 2006 3:28 am

oops, totally forgot about this.

The template makefiles expect to find the source code in a directory called 'source'. The error you get is usually due to the makefile being unable to find any source files at all.
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog

#93271 - tepples - Tue Jul 18, 2006 5:42 am

psycorpse wrote:
You should have your .bin files in a folder called data. In your makefile you should add something like the following:

Does this work if my binary files are generated from other binary files, which in turn are generated from still other binary files? Test case: a .gbfs made of multiple .todbg files, each converted from one .bmp file. Test case 2: a .gbfs made of multiple .gsm files, each converted from one .wav file.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#93477 - spencer723 - Wed Jul 19, 2006 12:54 pm

Thanks for the help wintermute