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 > compiler question

#124605 - beamer30 - Sat Apr 07, 2007 6:21 am

ok i can't seem to compile any file i always get 1 of two errors.

error 1 and makefile 1

Code:
ERROR:

C:\Documents and Settings\Game Wizard\Desktop\keys_demo1>make
arm-elf-g++ -g -Wall -O2 -mcpu=arm7tdmi -mtune=arm7tdmi -fomit-frame-pointer -ff
ast-math -mthumb-interwork -I/c/devkitPro/libnds/include -DARM7 -c arm7_main.cpp
 -oarm7_main.o
make: arm-elf-g++: Command not found
make: *** [arm7_main.o] Error 127

C:\Documents and Settings\Game Wizard\Desktop\keys_demo1>

MAKEFILE:

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

all: keys_demo1.nds.gba

arm-eabi-gcc -g -c -Wall -O3 -mcpu=arm7tdmi -mtune=arm7tdmi -fomit-frame-pointer -ffast-math -mthumb -mthumb-interwork -Ic:/devkitPro/libgba/include characters.c -o characters.o

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

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

keys_demo1.nds.gba: keys_demo1.nds
   dsbuild keys_demo1.nds -o keys_demo1.nds.gba

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




heres the other one

Code:
ERROR


C:\Documents and Settings\Game Wizard\Desktop\demo1>make
basename: too many arguments
Try `basename --help' for more information.
make[1]: /c/Documents: No such file or directory
make[1]: *** No rule to make target `/c/Documents'.  Stop.
make: *** [build] Error 2

C:\Documents and Settings\Game Wizard\Desktop\demo1>

MAKEFILE

#---------------------------------------------------------------------------------
.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      :=   gfx source data 
INCLUDES   :=   include build

#---------------------------------------------------------------------------------
# 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) -fno-rtti -fno-exceptions

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)
 
#---------------------------------------------------------------------------------
# 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))
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,$(SOURCES),$(notdir $(wildcard $(dir)/*.bin)))
 
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
   export LD   :=   $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
   export LD   :=   $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------

export OFILES   :=   $(BINFILES:.bin=.o) \
               $(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).nds   :    $(OUTPUT).arm9
$(OUTPUT).arm9   :   $(OUTPUT).elf
$(OUTPUT).elf   :   $(OFILES)
 
#---------------------------------------------------------------------------------
%.o   :   %.bin
#---------------------------------------------------------------------------------
   @echo $(notdir $<)
   $(bin2o)
 
 
-include $(DEPENDS)
 
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------




is the code or is because im trying to compile in windows command line?

also do i have to compile with msys because if so i've got question about it too.

#124614 - Cearn - Sat Apr 07, 2007 7:49 am

beamer30 wrote:
ok i can't seem to compile any file i always get 1 of two errors.

error 1 and makefile 1

Code:
ERROR:

C:\Documents and Settings\Game Wizard\Desktop\keys_demo1>make
arm-elf-g++ -g -Wall -O2 -mcpu=arm7tdmi -mtune=arm7tdmi -fomit-frame-pointer -ff
ast-math -mthumb-interwork -I/c/devkitPro/libnds/include -DARM7 -c arm7_main.cpp
 -oarm7_main.o
make: arm-elf-g++: Command not found
make: *** [arm7_main.o] Error 127

C:\Documents and Settings\Game Wizard\Desktop\keys_demo1>

MAKEFILE:

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

all: keys_demo1.nds.gba

<snip>

DevkitPro creates a number of environment variables to make it easier to find the paths to the binaries. However, it doesn't actually create one for the the path the binaries are in. As far as I can see, that makefile doesn't either.
The path you need is (DEVKITARM)/bin. You can add this to the path manually, or inside the makefile by adding the following line near the top:
Code:
PATH   := $(DEVKITARM)/bin:$(PATH)

This line can also be found in 'base_rules', which is included in 'ds_rules', which is included in the second makefile, which is why it can find it in that case.

The second problem is because you have spaces in the path.
beamer30 wrote:
Code:
ERROR

C:\Documents and Settings\Game Wizard\Desktop\demo1>make
basename: too many arguments
Try `basename --help' for more information.
make[1]: /c/Documents: No such file or directory
make[1]: *** No rule to make target `/c/Documents'.  Stop.
make: *** [build] Error 2

C:\Documents and Settings\Game Wizard\Desktop\demo1>
<snip>

include $(DEVKITARM)/ds_rules

<snip>


Look closely at the first error make gives: "make[1]: /c/Documents: No such file or directory". The tools used inside makefiles are Unix tools, which expect spaces to indicate separators between command-line options. In this case the tool 'basename' sees
Code:
C:\Documents and Settings\Game Wizard\Desktop\demo1

and parses it as
Code:
C:\Documents
and
Settings\Game
Wizard\Desktop\demo1

instead of as one directory. And then gets confused. The solution would be to not use paths with spaces in them. This probably goes for the first problem as well. Don't use the standard Windows directories here: make some new ones that don't have spaces and use those.

#124615 - beamer30 - Sat Apr 07, 2007 7:54 am

wait so basicaly if i put my desktop in my c drive it would work right cause theres no spaces? Also i added the code and i still get the error message.

#124622 - MrD - Sat Apr 07, 2007 10:01 am

Anything within 'Documents and settings' is a one-way ticket to making DKP explode.

Stick with something simple like C:\Prog\devkitPro, and C:\Prog\DS_Projects\Stuff
_________________
Not active on this forum. For Lemmings DS help see its website.

#124624 - Cearn - Sat Apr 07, 2007 10:18 am

The full path of the desktop is:
C:\Documents and Settings\[username]\Desktop
In other words, it has spaces.

If you have problems with tutorial projects or the examples that are in the devkitPro distribution, it's probably an issue with paths -- in particular spaces in paths. Read the error messages to see where the problem could be. Check the PATH variable (type PATH in the command prompt) and look through it for potential problems. You can also see the path in the system variables. Right-click 'My computer', then Properties>Advanced>Environment variables>System variables. For a little more, see http://www.devkitpro.org/setup.shtml.

#124651 - tepples - Sat Apr 07, 2007 4:37 pm

Cearn wrote:
The full path of the desktop is:
C:\Documents and Settings\[username]\Desktop
In other words, it has spaces.

This is fixed in Windows Vista, where "Documents and Settings" is called "Users", but unfortunately Windows Vista introduces other incompatibilities.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#124672 - Sektor - Sat Apr 07, 2007 6:20 pm

In the makefile, you need to replace *arm-elf* with arm-eabi. Those tutorials are outdated, so you will get many other errors.
_________________
GTAMP.com/DS

#124702 - beamer30 - Sat Apr 07, 2007 9:41 pm

ok i will change the code and get back to you guys, but what if i replace the spaces in my directiories with "_'s" so it becomes:

Code:
C:\Documents_and_Settings\Game_wizard\Desktop


would that work?

edit: ok i replaced the code like you said and heres what i got
Code:

C:\Documents and Settings\Game Wizard\Desktop\keys_demo1>make
arm-eabi-g++ -g -Wall -O2 -mcpu=arm7tdmi -mtune=arm7tdmi -fomit-frame-pointer -f
fast-math -mthumb-interwork -I/c/devkitPro/libnds/include -DARM7 -c arm7_main.cp
p -oarm7_main.o
arm7_main.cpp:6: error: stray '$' in program
arm7_main.cpp:6: error: stray '$' in program
arm7_main.cpp:6: error: invalid function declaration
arm7_main.cpp:19: error: 's32' does not name a type
arm7_main.cpp:20: error: 's32' does not name a type
arm7_main.cpp:21: error: 's32' does not name a type
arm7_main.cpp:22: error: 's32' does not name a type
arm7_main.cpp:27: error: 'uint32' has not been declared
arm7_main.cpp:27: error: 'u8' has not been declared
arm7_main.cpp:27: error: 'u8' has not been declared
arm7_main.cpp:27: error: 'u8' has not been declared
arm7_main.cpp:27: error: 'u8' has not been declared
arm7_main.cpp: In function 'void startSound(int, const void*, int, int, int, int
, int)':
arm7_main.cpp:28: error: 'vint16' was not declared in this scope
arm7_main.cpp:28: error: expected primary-expression before ')' token
arm7_main.cpp:29: error: 'vuint32' was not declared in this scope
arm7_main.cpp:29: error: expected primary-expression before ')' token
arm7_main.cpp:29: error: 'uint32' was not declared in this scope
arm7_main.cpp:29: error: expected `;' before 'data'
arm7_main.cpp:30: error: expected primary-expression before ')' token
arm7_main.cpp:31: error: expected primary-expression before ')' token
arm7_main.cpp: At global scope:
arm7_main.cpp:35: error: 's8' does not name a type
arm7_main.cpp: In function 'void InterruptHandler()':
arm7_main.cpp:49: error: 'vuint32' was not declared in this scope
arm7_main.cpp:49: error: expected primary-expression before ')' token
arm7_main.cpp:49: error: expected `)' before numeric constant
arm7_main.cpp:116: error: expected primary-expression before ')' token
arm7_main.cpp:116: error: expected primary-expression before ')' token
arm7_main.cpp:116: error: expected `)' before numeric constant
arm7_main.cpp:116: error: expected `)' before ';' token
arm7_main.cpp:47: warning: unused variable 'heartbeat'
arm7_main.cpp: In function 'int main(int, char**)':
arm7_main.cpp:125: error: 'rtcReset' was not declared in this scope
arm7_main.cpp:128: error: 'vuint16' was not declared in this scope
arm7_main.cpp:128: error: expected primary-expression before ')' token
arm7_main.cpp:128: error: expected `)' before numeric constant
arm7_main.cpp:129: error: 'TransferRegion' was not declared in this scope
arm7_main.cpp:129: error: expected `)' before 'volatile'
arm7_main.cpp:129: error: expected `)' before ';' token
arm7_main.cpp:132: error: expected primary-expression before ')' token
arm7_main.cpp:132: error: expected `)' before numeric constant
arm7_main.cpp:133: error: '__irq_vector' was not declared in this scope
arm7_main.cpp:134: error: 'vuint32' was not declared in this scope
arm7_main.cpp:134: error: expected primary-expression before ')' token
arm7_main.cpp:134: error: expected `)' before numeric constant
arm7_main.cpp:135: error: expected primary-expression before ')' token
arm7_main.cpp:135: error: expected `)' before numeric constant
arm7_main.cpp:136: error: 'DISP_SR' was not declared in this scope
arm7_main.cpp:137: error: expected primary-expression before ')' token
arm7_main.cpp:137: error: expected `)' before numeric constant
arm7_main.cpp:140: error: 'swiWaitForVBlank' was not declared in this scope
make: *** [arm7_main.o] Error 1

C:\Documents and Settings\Game Wizard\Desktop\keys_demo1>


maybe the tuturials just super old?(if so do you guys know of any helpful tuts, if so please post a link here)

edit2: Ok guys i just put the game in a diferent director and it compiled perfectly(yay!!!!!!!!!) but the other one from the tut didn't work so i think its outdated.

Thanks for all you help guys i can finally start writing some real code now.

i just have one request though:

if any ne has an updated tut please post it here. :D

#124713 - Cearn - Sat Apr 07, 2007 11:03 pm

beamer30 wrote:
ok i will change the code and get back to you guys, but what if i replace the spaces in my directories with "_'s" so it becomes:

Code:
C:\Documents_and_Settings\Game_wizard\Desktop


would that work?

Possibly. Windows itself might not work properly afterwards anymore (it kinda relies on those directories for a number of things), but you might be able to get devkitPro to compile stuff.

beamer30 wrote:

edit: ok i replaced the code like you said and heres what i got
Code:

C:\Documents and Settings\Game Wizard\Desktop\keys_demo1>make
arm-eabi-g++ -g -Wall -O2 -mcpu=arm7tdmi -mtune=arm7tdmi -fomit-frame-pointer -f
fast-math -mthumb-interwork -I/c/devkitPro/libnds/include -DARM7 -c arm7_main.cp
p -oarm7_main.o
arm7_main.cpp:6: error: stray '$' in program
arm7_main.cpp:6: error: stray '$' in program
<snip more errors)
make: *** [arm7_main.o] Error 1

C:\Documents and Settings\Game Wizard\Desktop\keys_demo1>


maybe the tuturials just super old?(if so do you guys know of any helpful tuts, if so please post a link here)

edit2: Ok guys i just put the game in a diferent director and it compiled perfectly(yay!!!!!!!!!) but the other one from the tut didn't work so i think its outdated.

Thanks for all you help guys i can finally start writing some real code now.

i just have one request though:

if any ne has an updated tut please post it here. :D

There are a couple of out of date DS tutorials, yeah. If you want to be sure you have something up to date, start with the examples that come with devkitPro.

You could also start with GBA programming. GBA coding is pretty stable. The emulators are near-perfect with useful memory viewers, there's less worry about compatible flashkits and the main tutorial (tonc) is up to date and pretty well tested and documented (although it does assume prior C programming knowledge).
I'll also join with the recommendation to start on a PC platform too. C(++) programming can be a little tricky at times and the last thing you want to do is tearing your hair out over some silly pointer error (which you will make!). You have better debugging options on a PC and the tools should pretty much set themselves up automatically. Yes, it might be more boring, but you need to learn to crawl before you can walk. Let alone run.