IDE-less Environment

From wiki.gp2x.org

Contents

IDE-less Environment Example

Intro

This is an example how to make GP2X games without an IDE (Integrated Development Environment) like Dev-C++, Codeblocks or Microsoft Visual C++ but instead with plain text-editing programs like Notepad or Notepad2.

This example uses a makefile for both GP2X and Windows (testing) systems. The makefile requires you to have a premade directory structure (explained later) so you can organise your files (both source and compiled files).


Note: This can also be a good environment for just Windows games/applications. You can remove the GP2X stuff if you like (not nessecairy, though).

Note2: If you have a bit experience with makefiles you can easily adjust it to make applications for Linux or Mac, too.

Downloading and installing

Before you can use this you'll need to download the following:

  • devkitGP2X, for GP2X compilation
  • MinGW, for Windows compilation
  • MSys, for using makefiles
  • Your favorite text editor (like Notepad)


Note: See the MinGW site for more info about MinGW and MSys.

Note2: I installed devkitGP2X in my E: root (E:/devkitGP2X), MinGW in my C: root (C:/MinGW) and MSys in my MinGW folder (C:/MinGW/MSys).

Project directory structure

Now, you'll need to create the directory structure for your project:

  • projectname
    • _src
    • build
      • win32
      • gp2x


All sour source code files will go in _src (no subdirectories). Your makefile and batch files (explained later) will be in the projectname directory.

Leave 'build', 'build\win32' and 'build\gp2x' empty, they will be filled later with compiled source objects (.o files).

The makefile

Open 'makefile' (no extension) in your project directory, copy and paste this code:

PROJECT = test

# ---

ifdef GP2X
	SYSTEM = gp2x
	EXT = gpe
else
	SYSTEM = win32
	EXT = exe
endif

BIN = $(PROJECT).$(EXT)
OBJS = $(patsubst _src/%.cpp, build/$(SYSTEM)/%.o, $(wildcard _src/*.cpp))

CFLAGS = -Wall
LDFLAGS = -lSDL -lSDLmain

ifdef GP2X
	CFLAGS += -DGP2X

	LIBDIRS = -L"E:/devkitGP2X/lib"
	INCDIRS = -I"E:/devkitGP2X/include" -I"E:/devkitGP2X/include/SDL"

	CXX = E:/devkitGP2X/bin/arm-linux-g++
	STRIP = E:/devkitGP2X/bin/arm-linux-strip
else
	LIBDIRS = -L"C:/MinGW/lib"
	INCDIRS = -I"C:/MinGW/include"

	CXX = C:/MinGW/bin/g++
	STRIP = C:/MinGW/bin/strip
endif

ifdef DEBUG
	CFLAGS += -D_DEBUG
else
	CFLAGS += -O2
endif

# ---

all : $(BIN)

$(BIN): $(OBJS)
	$(CXX) -o $@ $^ $(LIBDIRS) $(LDFLAGS)

ifndef DEBUG
	$(STRIP) $(BIN)
endif

build/$(SYSTEM)/%.o : _src/%.cpp
	$(CXX) -o $@ $< $(INCDIRS) -c $(CFLAGS)

.PHONY clean:
	@rm -rfv build/$(SYSTEM)/*
	@rm -fv $(BIN)

As you can see its pretty straightforward. It's pretty easy to modify it to make Linux and/or Mac binaries, too.

Make Commands

Now, here are the commandline commands to make your program (be sure to add 'C:/MinGW/MSys/bin' to your enviroment variables!):

  • make, makes a Window version (optimised and stripped)
  • make DEBUG=1, makes a debug Windows version (for debugging)
  • make GP2X=1, makes a GP2X version (optimised and stripped)
  • make GP2X=1 DEBUG=1, makes a debug GP2X version (not recommended)
  • make clean, cleans up all the Windows stuff (exe, object files)
  • make clean GP2X=1, cleans up all the GP2X stuff (gpe, object files)


I've made batch files in my project directory so I can easily make (or clean up) my project with 2 clicks. Batch files are named '_make_gp2x.bat', '_make_win32_debug.bat', '_cleanup_gp2x.bat', etc.

Here's an example of my '_make_win32_debug.bat':

@echo off
make clean
make DEBUG=1
echo.
echo done
pause>NUL

Conclusion

Well, thats about it. I find this more easier working than a IDE (this is just my opinion, though). I hope this is helpful for some of you guys out there.

SharQueDo 13:16, 24 February 2007 (PST)

Personal tools