This guide aims to provide instructions on setting up a new compiler using the freeware IDE Dev-C++ (also known as DevCpp) by Bloodshed software.
Note: This article step by step has now been tested and it works well. The results runs on the GP2X without any problem. If something goes wrong along the way search and read the GP2X Development forums. If you have any remaining questions, post a new topic with a descriptive title or jump in on a relevant thread.
Install DevCpp and DevkitGP2X
- Download the latest version of DevCpp from Bloodshed software. It is probably best to get the package marked "with MinGW/GCC" because this comes with several important files aside from the compiler itself.
- Install using the setup program to a chosen directory. For my example I will be using C:\Dev-cpp (the default path)
- Download DevkitGP2X from Sourceforge
- You can go two ways from here. You can either put DevkitGP2X in a completely seperate directory from Devcpp, or as a subdirectory of the Devcpp root directory. Either is a valid option. Installing it in a seperate directory will keep things a little cleaner but it is a matter of personal choice- It is not so important. Either way, run the self extracting archive and choose the path to extract the files to your chosen location. For my example, I will use C:\DevKitGP2X (Since the archive contains its own directory called DevkitGP2X, this is the result of extracting to the root directory of the disk ie C:\)
Create a new compiler profile and configure it for devkitGP2X
- Go to the "Libraries" sub-tab, and repeat the process of the last tab, but replace the path with the DevkitGP2X "lib" path ("C:\devkitGP2X\lib"). In the "C Includes" and "C++ includes" sub-tabs, continue the process. By the path setup of this guide, the following substitutions are made:
Under the "C includes" sub-tab: C:\Dev-Cpp\include -> C:\devkitGP2X\include Under the "C++ includes" sub-tab: C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include -> C:\devkitGP2X\lib\gcc\arm-linux\4.0.2\include C:\Dev-Cpp\include\c++\3.4.2\backward -> C:\devkitGP2X\include\c++\4.0.2\backward C:\Dev-Cpp\include\c++\3.4.2\mingw32 -> C:\devkitGP2X\include\c++\4.0.2\arm-linux C:\Dev-Cpp\include\c++\3.4.2 -> C:\devkitGP2X\include\c++\4.0.2 C:\Dev-Cpp\include -> C:\devkitGP2X\include
- Finally, go to the "Programs" tab and replace the programs to use when compiling with the DevkitGP2X equivalents. Some do not have equivalents- leave those ones alone. You can use the directory view icon to locate them (they are located at "C:\DevkitGP2X\bin" in this example). The following are the changes to be made:
gcc.exe -> arm-linux-gcc.exe g++.exe -> arm-linux-g++.exe make.exe -> No equivalent gdb.exe -> No equivalent windres.exe -> No equivalent dllwrap.exe -> No equivalent gprof.exe -> arm-linux-gprof.exe
- Click OK to save your changes and exit the Compile Options dialog.
Creating a project
To make a new project and compile it with DevkitGP2X:
- Go to the "File" menu, and select New->Project
- Go to the "Project" menu and select "Project options" or hit ALT-P.
- Go to the "Compiler" tab. Under the drop down labeled "Compiler:" select the compiler profile you set up earlier.
- Note: This step is only necessary for projects using SDL and can otherwise be skipped. Go to the "Parameters" tab, and in the box labeled "linker", add the following parameters: -lSDLmain -lSDL
- To create .gpe (rather than .exe) files, go to the "Build Options" tab and check "Override Output Filename". Type the filename you want and end it with .gpe.
Compiling SDLTest by Guyfawkes using new compiler
- Download and install Guyfawkes precompiled libs
- Download and unzip the source code for SDLTest http://archive.gp2x.de/cgi-bin/cfiles.cgi?0,0,0,0,46,1047
- Start a new Empty Project in Dev-C++ (File menu -> New Project, Empty Project, C++ Project -> OK). You can save this new project in the unzipped sdltest-v### directory.
- Add sdltest.cpp & sdltest.h to your new Project (Project menu -> Add to Project)
- Goto Project menu > Project Options (or ALT+P). Under the Compiler tab select your devkitGP2X compiler.
- Goto Parameters tab and add the following into the Linker box:
-static -lSDL_mixer -lSDL_ttf -lSDL_image -lsmpeg -lmikmod -lvorbisidec -lfreetype -ljpeg -lpng12 -lz -lm -lSDL -lpthread
- Goto Build Options, and set Override output filename to "test.gpe". Hit OK to exit the dialog.
- Goto Execute menu > Compile (or CTRL+F9), test.gpe will be created in your sdltest directory
I recieve the following warning while compiling, but it doesn't stop the compile process:
Line File Message H:\devkitGP2X\lib\libmikmod.a(mdriver.o) In function `MD_DropPrivileges': 919 H:\devkitGP2X\Dev-C-4992\playercode\mdriver.c (Warning) Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from glibc version used for linking