#157477 - aquaspider - Sun May 25, 2008 9:05 am
Hello. I'm new here, but I've been lurking for a week or so, trying to soak up whatever I can. Can anybody help me with a small problem?
Specifically, I can't seem to get .cpp files to include the headers from libgba. This is the error message I get:
Here are the files in the project:
main.c:
main_two.c:
maincpp.cpp:
The two .c files compile just fine, but the .cpp one seems to barf on the libgba headers. As I check out the makefile, it doesn't seem to treat them any differently:
I'm working from the SimpleBGScroll example from devkitPro. I'm pretty certain I got the toolchain installed correctly. It built libgba from source. And before modifying it, I was able to compile SimpleBGScroll into a .gba rom file. Tried it out in an emulator; was even able to modify the message, recompile, and see the message change in the emulator.
Yet, cpp files can't include the libgba headers? I'm stumped. (It being 3:00 AM where I am may also play a role in this.)
I'm running Ubuntu 8.04 and installed devkitPro under my home directory if those are important details?
Thank you in advance for any assistance you can offer this new homebrew developer!
Specifically, I can't seem to get .cpp files to include the headers from libgba. This is the error message I get:
Code: |
aquaspider@vileplume:~/devkitPro/examples/gba/graphics/SimpleBGScroll$ make maincpp.cpp arm-eabi-g++ -MMD -MP -MF /home/aquaspider/devkitPro/examples/gba/graphics/SimpleBGScroll/build/maincpp.d -c /home/aquaspider/devkitPro/examples/gba/graphics/SimpleBGScroll/source/maincpp.cpp -o maincpp.o /home/aquaspider/devkitPro/examples/gba/graphics/SimpleBGScroll/source/maincpp.cpp:1:22: warning: gba_base.h: No such file or directory /home/aquaspider/devkitPro/examples/gba/graphics/SimpleBGScroll/source/maincpp.cpp:2:23: error: gba_video.h: No such file or directory make[1]: *** [maincpp.o] Error 1 make: *** [build] Error 2 aquaspider@vileplume:~/devkitPro/examples/gba/graphics/SimpleBGScroll$ |
Here are the files in the project:
main.c:
Code: |
#include <gba_base.h> #include <gba_video.h> int main() { //main_cpp(); return 0; } |
main_two.c:
Code: |
#include "gba_base.h" #include <gba_video.h> int main_two() { int a = 10; return a * 2; } |
maincpp.cpp:
Code: |
#include <gba_base.h> #include "gba_video.h" int cpp_function() { } |
The two .c files compile just fine, but the .cpp one seems to barf on the libgba headers. As I check out the makefile, it doesn't seem to treat them any differently:
Code: |
#--------------------------------------------------------------------------------- # Clear the implicit built in rules #--------------------------------------------------------------------------------- .SUFFIXES: #--------------------------------------------------------------------------------- ifeq ($(strip $(DEVKITARM)),) $(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM) endif include $(DEVKITARM)/gba_rules #--------------------------------------------------------------------------------- # TARGET is the name of the output, if this ends with _mb generates a multiboot image # 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 := SimpleBGScroll_mb BUILD := build SOURCES := source font INCLUDES := #--------------------------------------------------------------------------------- # options for code generation #--------------------------------------------------------------------------------- ARCH := -mthumb -mthumb-interwork CFLAGS := -g -Wall -O3\ -mcpu=arm7tdmi -mtune=arm7tdmi\ -fomit-frame-pointer\ -ffast-math \ $(ARCH) CFLAGS += $(INCLUDE) ASFLAGS := $(ARCH) LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $@).map #--------------------------------------------------------------------------------- # path to tools - this can be deleted if you set the path in windows #--------------------------------------------------------------------------------- export PATH := $(DEVKITARM)/bin:$(PATH) #--------------------------------------------------------------------------------- # any extra libraries we wish to link with the project #--------------------------------------------------------------------------------- LIBS := -lgba #--------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level containing # include and lib #--------------------------------------------------------------------------------- LIBDIRS := $(LIBGBA) #--------------------------------------------------------------------------------- # 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 PATH := $(DEVKITARM)/bin:$(PATH) export DEPSDIR := $(CURDIR)/$(BUILD) #--------------------------------------------------------------------------------- # automatically build a list of object files for our project #--------------------------------------------------------------------------------- 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) #--------------------------------------------------------------------------------- # build a list of include paths #--------------------------------------------------------------------------------- export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ -I$(CURDIR)/$(BUILD) #--------------------------------------------------------------------------------- # build a list of library paths #--------------------------------------------------------------------------------- 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).gba #--------------------------------------------------------------------------------- else DEPENDS := $(OFILES:.o=.d) #--------------------------------------------------------------------------------- # main targets #--------------------------------------------------------------------------------- $(OUTPUT).gba : $(OUTPUT).elf $(OUTPUT).elf : $(OFILES) $(LIBGBA)/lib/libgba.a %.o : %.bin @echo $(notdir $<) @$(bin2o) -include $(DEPENDS) #--------------------------------------------------------------------------------- endif #--------------------------------------------------------------------------------- |
I'm working from the SimpleBGScroll example from devkitPro. I'm pretty certain I got the toolchain installed correctly. It built libgba from source. And before modifying it, I was able to compile SimpleBGScroll into a .gba rom file. Tried it out in an emulator; was even able to modify the message, recompile, and see the message change in the emulator.
Yet, cpp files can't include the libgba headers? I'm stumped. (It being 3:00 AM where I am may also play a role in this.)
I'm running Ubuntu 8.04 and installed devkitPro under my home directory if those are important details?
Thank you in advance for any assistance you can offer this new homebrew developer!