Changes

Jump to navigation Jump to search
First draft complete.
<!-- This page is a WIP
Please leave suggestions /corrections on the talk page instead of editing directly, for now.
-->
The [http://www.eclipse.org/ Eclipse Platform] is a modern cross-platform & open source IDE with a built-in debugger GUI and support for several programming languages via plug-ins. Plug-ins can also be used to extend functionality. For many, programmerProgrammer's notepad Notepad (PN) and insight Insight will suffice, but others may find the combination a little out of date. This wiki will guide you through each stage in the setup process, but assumes that you are using Windows, have already installed [[devkitPro]] (including devkitPPC) and are relatively familiar with the concepts of developing Wii Homebrew. Adapting for Linux and other platforms should not be difficult.<br /> == About ==I needed a development environment to use while learning C/C++, and Eclipse fit my needs. The more I used Eclipse, the more I tired of using PN, and began to look for the means to develop homebrew from within Eclipse. Unfortunately for me, there was no solid set of instructions available, and the nearest thing I found was a French guide for PSP development in Eclipse. This guide is the result of my search for information, and has been pieced together from the web, or simply learnt by experimentation, and I very much hope that it is of use to others ~ [[User:PhoenixTank|PhoenixTank]] | [[User talk:PhoenixTank|talk]] | [[Special:Contributions/PhoenixTank|contribs]] |
== Requirements ==
* [[DevkitProdevkitPro]] [http://www.devkitpro.org/]
* [http://www.java.com/en/download/manual.jsp JRE (Java Runtime Environment)] installed.
* A copy of ''Eclipse IDE for C/C++ Developers'' [http://www.eclipse.org/downloads/] '''Current Version:''' eclipse-cpp-ganymede-SR2-win32.zip
*You now see the main IDE with Project Explorer, File Editor, Console and others panes.
*There will be an error and a probably warning in the problems pane. Don't worry about them for now, and open C:\devkitPro\examples\wii\template\ in Windows Explorer. Select the Source folder and makefile, and copy them to clipboard. Return to Eclipse, right click the HelloWorld project in Project Explorer, and paste. The files should now be a part of your project.
*Head to Projects > Properties, or do the same from the right click menu of HelloWorld. Click ''"C/C++ Build'' " then choose the ''"behaviour'' " tab. Here, change the value of ''"Build (Incremental Build)'' " to ''"build'' " or simply blank, then hit OK. Alternatively, use a [[#Custom Make Targets|custom make target]] instead of the built in build.
*With default settings, Eclipse will immediately build your project. The error should no longer be there to pester you.
*If you have a warning like: Error launching external scanner info generator (gcc -E -P -v -dD C:/WiiDev/projects/.metadata/.plugins/org.eclipse.cdt.make.core/specs.cpp) then the easiest way to fix this is to add C:\devkitPro\devkitPPC\powerpc-gekko\bin; to the start of your [[#Path|path]] environment variable.
Eclipse is quite customisable, but the large amount of settings can be a struggle to wade through, in order to find what you are looking for.
I have some personal preferences that may be of interest to others.
 
From Window > Preferences:
*General ¬ Workspace. ''"Build automatically'' " unchecked, ''"Save automatically before build'' " checked.
*C/C++ ¬ Code Style. I use BSD/Allman, but the other most common styles are there too.
*C/C++ ¬ Editor ¬ Content Assist. Drop the delay to 200 ms.
<!--*C/C++ ¬ New CDT project wizard ¬ Makefile Project : Behaviour tab. Uncheck ''"Build on resource save'', change value of ''Build (Incremental Build)'' to ''build''--->"
== Debugging ==
'''*****This section is still being worked on, and is incomplete.*****'''
 
The Eclipse CDT has a nice integrated debugging GUI (which is half of the reason for this tutorial), but unfortunately does not support remote C/C++ applications "out of the box". To get around this Eclipse needs to be extended, and we are lucky enough to have a plug-in available to us. [http://opensource.zylin.com/embeddedcdt.html]
*Name it HelloWorld GDB or other relevant name, but bear in mind that it will need to be unique across all Eclipse projects.
From here, I'll explain settings tab by tab, as there are several ways to achieve the same setup.
 
==== Main tab ====
*Adding your project name is optional, and may or may not be filled in for you already. It only seem to enable the Search Project button below, which doesn't actually do anything useful for us.
==== Debugger tab ====
*GDB debugger - enter the path "C:\devkitPro\devkitPPC\bin\powerpc-gekko-gdb.exe". '''This one is required.'''
*GDB command file - As an alternative to the commands tab, you can specify an external file containing GDB commands to run. Blank the field if you aren't going to use it. This may be useful if, for example, your Wii can't be assigned a static IP. Using a single command file that is updated to target the new Wii IP is easier than editing the config in each project.
*Protocol - Keep it as "mi". I haven't tested for any differences yet.
==== Wifi Debugging Patch ====
AKA "The poor man's USB Gecko". This takes a little work to implement, but at a total cost of £0, who can complain? You'll need to be familiar with checking out from a SVN, patching source files, and compiling libogc from source.
===== Setting up the patch =====
*Check out libogc source from SVN from: https://devkitpro.svn.sourceforge.net/svnroot/devkitpro/trunk/libogc*Eclipse has a SVN client plugin that you may like. [http://subclipse.tigris.org/servlets/ProjectProcess?pageID=p4wYuA Subclipse]
*Apply tcpipwifi.patch from: http://sourceforge.net/tracker/?func=detail&aid=2707076&group_id=114505&atid=668553
*Compile libogc and install.
 ===== Setting up example for debugging =====By this point we have the template compiling nicely and our Wii sends greetings to the world, but to we have to follow some steps to actually get it working:*???In your makefile's LIBS section add -ldb '''before -logc''' . For your CFLAGS/CXXFLAGS, change -O2 to -O0 for any debug builds.*ProfitYou need to add "#include <debug.h>" in template.cDebugging can needs to be started by adding these lines to your application's code:<pre>DEBUG_Init(GDBSTUB_DEVICE_WIFI, 8000); // Port 8000 (use whatever you want)_break();</pre>There doesn't seem to be an issue with where you place it, but I'd advise that it is shortly after video is initialised and the console is ready. This allows the Wii-side of the debugger to output text:<!-- Verbatim output - Typo is part of patch. ---><pre>Getting Wii IP adress.Wii IP address: 192.168.0.5Port: 8000Waiting for debugger to connect...Debugger connected.</pre>When using the template and other applications, know that using printf("\x1b[2;0H");or similar to position the console cursor is going to cause new output to overwrite the previous debugger output.
===== Example GDB target command =====
target remote 192.168.0.5:8000
A GDB command like the one above is needed in either your external GDBinit file ([[#Debugger tab|debugger tab]]), the internal Eclipse config ([[#Commands tab|commands tab]]) or can be typed in to the GDB console manually. Without this, GDB doesn't know what to attach to.
== Credits ==
*[http://forum.wiibrew.org/read.php?11,12220Wiibrew forum: Wifi Debugging]*[http://forum.wiibrew.org/read.php?11,17444Wiibrew forum: Insight]*[[Debugging|Wiibrew Debugging Guide]] == To Do ==*Link to a helpful guide to using GDB (recommendations welcome)*New Wii Homebrew Project Wizard Plug-in (I'll need to learn Java, unless someone else steps up) [[Category:Development]]
78

edits

Navigation menu