Using Devcpp

From wiki.gp2x.org

Contents

Introduction

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

  1. 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.
  2. Install using the setup program to a chosen directory. For my example I will be using C:\Dev-cpp (the default path)
  3. Download DevkitGP2X from Sourceforge
  4. 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

  1. Ferentix DevCppCompilerOptions.PNG
    Run Devcpp. Click on the "Tools" drop down menu, then select the "Compiler Options" item from the list.
  2. Ferentix DevCppCompilerProfiles.PNG
    There should be a combo box containing the name of the compiler set to be configured. By default this should be "Default compiler". Click the plus (+) icon to add a new compiler set. You will be prompted to enter a name which is arbitrary. However, it's good to use descriptive naming conventions so I called mine "DevkitGP2X". The "Compiler Set To Configure" drop down should display the name of your new compiler.
  3. Ferentix DevCppSetPaths.PNG
    Select the "Directories" tab. There are several sub tabs on this page: Binaries, Libraries, C Includes and C++ includes. In the "Binaries" sub-tab, there should be a path like "C:\Dev-Cpp\Bin". Click the tree view icon in the bottom right corner to find the path of your DevkitGP2X "bin" directory or if you already know it enter it into the text box to the left of that button. In the example it is "C:\devkitGP2X\Bin". Select the original path from the list box and click replace.
  4. 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
    


  5. 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
    
  6. 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:

  1. Go to the "File" menu, and select New->Project
  2. Ferentix DevCppNewProjectDialogue.PNG
    Select "Empty project", and choose the language you wish to use (C or C++). Hit OK or ALT-O.
  3. Go to the "Project" menu and select "Project options" or hit ALT-P.
  4. Go to the "Compiler" tab. Under the drop down labeled "Compiler:" select the compiler profile you set up earlier.
  5. 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
  6. 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

  1. Download and install Guyfawkes precompiled libs
  2. Download and unzip the source code for SDLTest http://archive.gp2x.de/cgi-bin/cfiles.cgi?0,0,0,0,46,1047
  3. 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.
  4. Add sdltest.cpp & sdltest.h to your new Project (Project menu -> Add to Project)
  5. Goto Project menu > Project Options (or ALT+P). Under the Compiler tab select your devkitGP2X compiler.
  6. 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
  7. Goto Build Options, and set Override output filename to "test.gpe". Hit OK to exit the dialog.
  8. 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
Personal tools