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 > Libnds weird error.

#120610 - bugmenot! - Mon Mar 05, 2007 12:20 am

I am trying to compile my nds code and I get this error. I have no clue what it means. Can anyone tell me whats wrong?
[img]http://farm1.static.flickr.com/164/410571397_34292d457e.jpg?v=0[/img]

#120621 - simonjhall - Mon Mar 05, 2007 1:14 am

We'd need to see the makefile in order to fix this. However, if you have no rules defined telling make how to build that file or files with that extension then you'll get the error you see there.
_________________
Big thanks to everyone who donated for Quake2

#120677 - bugmenot! - Mon Mar 05, 2007 1:36 pm

Here is the make file. Its from the Patersoft tutorial.
Code:
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------

ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif

include $(DEVKITARM)/ds_rules

#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
#---------------------------------------------------------------------------------
TARGET      :=   $(shell basename $(CURDIR))
BUILD      :=   build
SOURCES      :=   source
DATA      :=   data 
INCLUDES   :=   include

#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH   :=   -mthumb -mthumb-interwork

# note: arm9tdmi isn't the correct CPU arch, but anything newer and LD
# *insists* it has a FPU or VFP, and it won't take no for an answer!
CFLAGS   :=   -g -Wall -O2\
          -mcpu=arm9tdmi -mtune=arm9tdmi -fomit-frame-pointer\
         -ffast-math \
         $(ARCH)

CFLAGS   +=   $(INCLUDE) -DARM9
CXXFLAGS   := $(CFLAGS)

ASFLAGS   :=   -g $(ARCH)
LDFLAGS   =   -specs=ds_arm9.specs -g $(ARCH) -mno-fpu -Wl,-Map,$(notdir $*.map)

#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS   := -lnds9
 
 
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS   :=   $(LIBNDS) $(GBA_NDS_FAT_LIB)
 
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
 
export OUTPUT   :=   $(CURDIR)/$(TARGET)
 
export VPATH   :=   $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
               $(foreach dir,$(DATA),$(CURDIR)/$(dir))

export DEPSDIR   :=   $(CURDIR)/$(BUILD)

CFILES      :=   $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES   :=   $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES      :=   $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES   :=   $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
 
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
   export LD   :=   $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
   export LD   :=   $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------

export OFILES   :=   $(addsuffix .o,$(BINFILES)) \
               $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
 
export INCLUDE   :=   $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
               $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
               $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
               -I$(CURDIR)/$(BUILD)
 
export LIBPATHS   :=   $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
 
.PHONY: $(BUILD) clean
 
#---------------------------------------------------------------------------------
$(BUILD):
   @[ -d $@ ] || mkdir -p $@
   @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
 
#---------------------------------------------------------------------------------
clean:
   @echo clean ...
   @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(TARGET).arm9 $(TARGET).ds.gba
 
 
#---------------------------------------------------------------------------------
else
 
DEPENDS   :=   $(OFILES:.o=.d)
 
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).ds.gba   :    $(OUTPUT).nds
$(OUTPUT).nds   :    $(OUTPUT).arm9
$(OUTPUT).arm9   :   $(OUTPUT).elf
$(OUTPUT).elf   :   $(OFILES)

#---------------------------------------------------------------------------------
# bin2o rules
#---------------------------------------------------------------------------------

%.bin.o   :   %.bin
   @echo $(notdir $<)
   @$(bin2o)

%.raw.o   :   %.raw
   @echo $(notdir $<)
   @$(bin2o)

 
-include $(DEPENDS)
 
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

#120683 - tepples - Mon Mar 05, 2007 2:59 pm

bugmenot! wrote:
I am trying to compile my nds code and I get this error. I have no clue what it means. Can anyone tell me whats wrong?
[img]http://farm1.static.flickr.com/164/410571397_34292d457e.jpg?v=0[/img]

Tip: You can copy text from the Command Prompt and paste it into a forum post. I just added instructions to "The basics" in the FAQ in the Beginners forum.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#120801 - wintermute - Tue Mar 06, 2007 4:49 am

bugmenot! wrote:
I am trying to compile my nds code and I get this error. I have no clue what it means. Can anyone tell me whats wrong?
[img]http://farm1.static.flickr.com/164/410571397_34292d457e.jpg?v=0[/img]



You have a file in the data directory called graph_bin.h

Perhaps this file came from using one of the idiotic .bin to .h converters on a file called graph.bin, also in the data directory?
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog

#120807 - tepples - Tue Mar 06, 2007 5:40 am

That is, unless it's from a less-idiotic converter that spits out .c and a proper .h, or .s and a proper .h (like my bin2s that was included into devkitARM), or .o and a proper .h (like the bin2o script included with the GBA and DS makefile rules).
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#120841 - bugmenot! - Tue Mar 06, 2007 1:38 pm

I think that is the problem. I will try and test it out tonight. By the way, why is the .bin format better then just using header files?

#120843 - tepples - Tue Mar 06, 2007 1:46 pm

A header file is supposed to specify the names of structs, external variables, and external functions, and that's it. The actual content of the data should be in a .c or .s file.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#121000 - bugmenot! - Thu Mar 08, 2007 12:58 am

Ok, I removed the header file from the data directory and now I get another error.
Code:
C:\dsink>make
linking dsink.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/dsink/dsink.elf] Error 1
make: *** [build] Error 2

This is driving me crazy, does anyone know what I am supposed to do? I have never heard of the function "CIDLoop".

#121040 - OOPMan - Thu Mar 08, 2007 11:24 am

Try rebuilding your project from scratch...

By this I mean you should make a copy of one of the template project directories included with DKP and then move your source files and data files into it very carefully. Don't copy any object files or any other files produced during compilation...

If you're not using any data files, this means you'll be copying only .H and .C or .CPP files.
_________________
"My boot, your face..." - Attributed to OOPMan, Emperor of Eroticon VI

You can find my NDS homebrew projects here...

#121105 - josath - Thu Mar 08, 2007 11:50 pm

bugmenot! wrote:
Ok, I removed the header file from the data directory and now I get another error.
Code:
C:\dsink>make
linking dsink.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/dsink/dsink.elf] Error 1
make: *** [build] Error 2

This is driving me crazy, does anyone know what I am supposed to do? I have never heard of the function "CIDLoop".


That error says you have no main() function in any of your .c or .cpp files. (That's what it means by "undefined reference to main").