Problems with grit

Support for the gba/ds graphics converter

Problems with grit

Postby Alriightyman » Fri Nov 06, 2009 5:27 pm

Ok, so EVERYTIME I compile a project using grit it does two things:
First, it can't find (graphicname).h. This forces me to use grit manually, not that its a big deal but just a little anoying. Also, if i compile any of the example code, it ALWAYS works.
Second, after I convert them manually, it gives an error:
Code: Select all
C:/...../source/main.cpp(63): undefined reference to `(graphicname)Tiles'

What am I doing wrong?
If it helps, I am using VS 2008. I know it is not VS 2008 because I can complie any of the example code just fine.
Oh and where do you put your (graphicname).h file at? I have them in the include folder otherwise they cannot be found.
Alriightyman
 
Posts: 8
Joined: Tue Oct 27, 2009 1:24 am

Re: Problems with grit

Postby vuurrobin » Fri Nov 06, 2009 9:50 pm

check to see if (graphicname).h is created (it should be in the build directory) when using grit automaticly.

if the compiler can find the (graphicname).h when using grit manually, but (graphicname)Tiles isn't defined, then the grit options are probably wrong. maybe you converted the image to bitmap instead of a tiled image.


did you use some VS 2008 template project? its possible that that project has an wrong or old makefile. if you fix or replace the makefile (with one of the examples) then you should be able to use grit automaticly.
User avatar
vuurrobin
 
Posts: 195
Joined: Fri Jul 11, 2008 7:49 pm
Location: the netherlands

Re: Problems with grit

Postby Alriightyman » Sat Nov 07, 2009 1:25 am

Actually I am using a project file. However, I did manage to fix it. The (Graphicname).h file needed to be in the source folder... How would I change the location for it so the compiler knows where to look?
Also, do you want me to post my makefile? I'm new to this makefile, I am used to just running a batch file to compile things...
Sorry if these are stupid questions.
Alriightyman
 
Posts: 8
Joined: Tue Oct 27, 2009 1:24 am

Re: Problems with grit

Postby vuurrobin » Sat Nov 07, 2009 4:13 pm

the source folder is only used for c/cpp files with the makefiles of devkitPro. not sure if putting header files in it is wrong, but if it works, then I guess its fine.

sure, go ahead and post your makefile. I'll try to see something wrong with it.
User avatar
vuurrobin
 
Posts: 195
Joined: Fri Jul 11, 2008 7:49 pm
Location: the netherlands

Re: Problems with grit

Postby Alriightyman » Mon Nov 09, 2009 2:43 pm

Well, here it is.
Code: Select all
#---------------------------------------------------------------------------------
.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
# DATA is a list of directories containing binary files embedded using bin2o
# GRAPHICS is a list of directories containing image files to be converted with grit
#---------------------------------------------------------------------------------
TARGET      :=   $(shell basename $(CURDIR))
BUILD      :=   build
SOURCES      :=   source
INCLUDES   :=   include
DATA      :=   data 
GRAPHICS   :=   gfx 

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

CFLAGS   :=   -g -Wall -O2\
      -march=armv5te -mtune=arm946e-s -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) -Wl,-Map,$(notdir $*.map)

#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project (order is important)
#---------------------------------------------------------------------------------
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)) \
               $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \
               $(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir))

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

CFILES      :=   $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES   :=   $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
PNGFILES   :=   $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.png)))
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)) \
               $(addsuffix .o,$(PNGFILES)) \
               $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)

export INCLUDE   :=   $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir)) \
               $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
               -I$(CURDIR)/$(BUILD)

export LIBPATHS   :=   $(foreach dir,$(LIBDIRS),-L$(dir)/lib)

icons := $(wildcard *.bmp)

ifneq (,$(findstring $(TARGET).bmp,$(icons)))
   export GAME_ICON := $(CURDIR)/$(TARGET).bmp
else
   ifneq (,$(findstring icon.bmp,$(icons)))
      export GAME_ICON := $(CURDIR)/icon.bmp
   endif
endif

.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

#---------------------------------------------------------------------------------
else

#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).nds   :    $(OUTPUT).arm9
$(OUTPUT).arm9   :   $(OUTPUT).elf
$(OUTPUT).elf   :   $(OFILES)

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

#---------------------------------------------------------------------------------
# This rule creates assembly source files using grit
# grit takes an image file and a .grit describing how the file is to be processed
# add additional rules like this for each image extension
# you use in the graphics folders
#---------------------------------------------------------------------------------
%.s %.h   : %.png %.grit
#---------------------------------------------------------------------------------
   grit $< -fts -o$*

-include $(DEPSDIR)/*.d

#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------
Alriightyman
 
Posts: 8
Joined: Tue Oct 27, 2009 1:24 am

Re: Problems with grit

Postby StevenH » Mon Nov 09, 2009 2:59 pm

Where are you putting your .png graphics for the game?

There's a bug in the makefiles the line that reads:

PNGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.png)))

Should read:

PNGFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.png)))

This will then invoke the correct grit rules to generate the .s and .h files in the ./build directory for your graphics. If you are not using png files, then you will need to edit / add a couple of other rules as well.

The directories and what I have in them are as follows:

SOURCES (source) - *.c *.cpp
INCLUDES (include) - *.h *.hpp
GRAPHICS (gfx) - *.png *.grit
BUILD (build) - *.o *.d *.map *.h *.s (the *.h and *.s files are generated by grit and the bin2o applications which are invoked by the makefile)
StevenH
 
Posts: 126
Joined: Sun Feb 22, 2009 6:59 pm


Return to grit

Who is online

Users browsing this forum: No registered users and 1 guest