GP2X Makefile Using Minimal.c


taras

Mega Pandora mania
Joined
Jun 17, 2003
Messages
934
Location
Scotland
Website
taras.net
This is probably really simple. I want to compile something using SDL *and* Rlyeh's Minimal lib. Where do I stick the minimal.c in the SDL makefile? I'm using the makefile from GuyFawkes's demo (plus -lSDL_gfx for SDL_gfx):

Code:
CROSS_COMPILE = C:/devkitGP2X/bin/arm-linux-
SDL_BASE = C:/devkitGP2X/bin/arm-linux-
LDFLAGS = -static

CC = $(CROSS_COMPILE)gcc
CXX = $(CROSS_COMPILE)g++
STRIP = $(CROSS_COMPILE)strip

CFLAGS = `$(SDL_BASE)sdl-config --cflags` -O2 -Wall -Werror
CXXFLAGS = `$(SDL_BASE)sdl-config --cflags` -O2 -Wall -Werror
LIBS = -lSDL_gfx `$(SDL_BASE)sdl-config --libs`

SDLTEST_TARGET = demo.gpe
SDLTEST_OBJS = demo.o

all : $(SDLTEST_TARGET)

$(SDLTEST_TARGET) : $(SDLTEST_OBJS)
	$(CXX) $(LDFLAGS) -o $(SDLTEST_TARGET) $(SDLTEST_OBJS) $(LIBS)
	$(STRIP) $(SDLTEST_TARGET)

clean:
	rm -f $(ALL_TARGETS) *.o *~

I just need to make it compile minimal.c somewhere in there. Or perhaps some other way. It's driving me mad.. :blink: cheers
 
Squidge - I did:

Code:
SDLTEST_OBJS = demo.o minimal.o

But then I get the error:

Code:
minimal.o: In function `gp2x_sound_play':
minimal.c:(.text+0x494): undefined reference to `gp2x_sound_frame'

EDIT:
I added the

Code:
void gp2x_sound_frame(void *blah, void *buff, int samples) {}

from Rlyeh's tutorial examples into minimal.c and it seems to have made it work.
 
add something like
Code:
void gp2x_sound_frame(void*,void*,int) {}
to your main (I assume you don't want to use sound)
 
Actually, it's not working again... because as soon as I try to use:

Code:
  getPad = gp2x_joystick_read();
  if ( getPad & GP2X_START ) { myquit=1; }

(ie. input detection as defined in minimal.c), from within demo.cpp, it says it's undefined. Which is fair enough, because it isn't --

so I just stuck a #include "minimal.c" at the start of my code. Hope that doesn't cause problems......
 
erk! There should be a header file with those function names (gp2x_joystick_read, etc), which you #include, and then compile minimal.c seperately by adding it to SDLTEST_OBJS. You really shouldn't #include the minimal.c file.

but, if you can't get that to work, then using #include "minimal.c" is a good alternative and saves the faffing around trying to make it work :)
 
Wellll that's the weird thing, I tried including minimal.h and adding minimal.o to the makefile but it refuses to work, saying the functions from minimal.c that I'm using are undefined.
 
If your code is C++ (.cc, .cpp, or .C extension) then it may mean minimal.h isn't correctly wrappen in 'extern "C"'. Renaming minimal.c to minimal.cc is one easy fix.

Note the .C being capital there - lower case .c is normal C code, so that would be ok.
 
Nope, renaming it doesn't work either - same errors. The only thing that seems to work is including minimal.c :(
 
renaming minimal.c to mnimal.cpp, so that it was compiled with g++ like the rest of my project worked
 
Back
Top