Ok, Im An Idiot


PSyMastR

\m/O__O\m/
Joined
Sep 14, 2005
Messages
2,968
Website
Visit site
Ive read the doccumentation everywhere, and stuff. Im a big Java/php programmer, and by reading C code for about 5 min, I figured out how it works, and stuff. I setup the devkitGP2X on a windows PC fine, and it compiles the demo app. Now, I want to create my own stuff, ive written a program, but it wont compile, as the makefile keeps asking me for this demo.o file. I put in the demo.o file (renamed it to demo2.o) into the same directory as the program i want to compile, and now it tells me its the wrong object file or whatever. What should my makefile look like for that devkit so I dont have to use object files or are they a must, and if so, how can I make my own, as they look like precompiled code.

Jeff (AKA PSyMastR)

P.S. here is my current makefile code (default makefile)

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 = `$(SDL_BASE)sdl-config --libs`

SDLTEST_TARGET = demo2.gpe
SDLTEST_OBJS = demo2.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 *~
Yes, I know what these lines do, and yes i know i can rename them and stuff...
SDLTEST_TARGET = demo2.gpe
SDLTEST_OBJS = demo2.o
 
Code:
...
LIBS = `$(SDL_BASE)sdl-config --libs`

SDLTEST_TARGET = demo2.gpe
SDLTEST_OBJS = demo2.o
...
$(SDLTEST_TARGET) : $(SDLTEST_OBJS)
	$(CXX) $(LDFLAGS) -o $(SDLTEST_TARGET) $(SDLTEST_OBJS) $(LIBS)
...

It looks like you're trying to feed "demo2.o", which is an object file, to g++ as source code. Where's the source you're trying to compile?
 
Maybe the problem here is with tab characters. 'make' requires tabs before any commands that it's actually going to run. This forum software doesn't display any tabs in entries, so maybe your makefile does have them after all...

Certainly, the clean target needs a tab, as in:
Code:
clean:
<tab>rm -f $(ALL_TARGETS) *.o *~
Now the rest of it is pretty simple. The bottom-level target is $(SDLTEST_OBJS), which expands to just one target, "demo2.obj". You haven't provided a rule for producing demo2.obj, and that's probably going to be a problem for you because make has what's called "intrinsic rules". One of these rules is that if a .o file is needed and there's no rule to produce it, then make will run
Code:
gcc -o <filename>.o -c <filename>.c
This is probably not right, because you want it to run "arm-linux-gcc" rather than just gcc. To fix this, add an explicit rule for turning a .c into a .o:
Code:
%.o: %.c
<tab>$(CC) $(CFLAGS) -c $< -o $@
Note that this will still work even if you have multiple C files, for example if
Code:
SDLTEST_OBJS=demo2.obj demo2extra.obj
If you actually want to build C++ files, then the concept is the same:
Code:
%.o:	%.cpp
<tab>$(CXX) $(CXXFLAGS) -c $< -o $@
Then your rule for producing $SDLTEST_TARGET also needs tabs, like:
Code:
$(SDLTEST_TARGET) : $(SDLTEST_OBJS)
<tab>$(CXX) $(LDFLAGS) -o $(SDLTEST_TARGET) $(SDLTEST_OBJS) $(LIBS)
<tab>$(STRIP) $(SDLTEST_TARGET)
Ah dammit, I might as well include the whole makefile now ;)
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 = `$(SDL_BASE)sdl-config --libs`

SDLTEST_TARGET = demo2.gpe
SDLTEST_OBJS = demo2.o

all : $(SDLTEST_TARGET)

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

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

%.o: %.c
<tab>$(CC) $(CFLAGS) -c $< -o $@

%.o: %.cpp
<tab>$(CXX) $(CXXFLAGS) -c $< -o $@
Please, you will remember to replace <tab> with an actual tab character, won't you? :D

If this doesn't work, post the actual messages that you get (not your translations!) and we'll see what we can do about it.
 
Ok, here ya go :D

Also, is a .o file needed?

Code:
C:\devkitGP2X\demo2>C:\devkitGP2X\MinSys\bin\make
C:/devkitGP2X/bin/arm-linux-gcc `C:/devkitGP2X/bin/arm-linux-sdl-config --cflags
` -O2 -Wall -Werror -c demo2.c -o demo2.o
demo2.c:28:2: error: no newline at end of file
make: *** [demo2.o] Error 1

C:\devkitGP2X\demo2>pause
Press any key to continue . . .

The last bit of that is just part of my .bat script so I can read the output.

EDIT: Bah, It was an error in my code, I forgot to put an empty line at the end of my .c source. Thanks for the updated makefile Robster :D Sorry to have bugged you guys.
 
Back
Top