Tip: setup debugging messages for Wii/GameCube applications
Here's a small piece of advice if you are into Wii/GameCube development and are not sure how to produce debug messages in a way that allows you to easily see them.
On the Dolphin emulator
This is the way I'd recommend you to debug your application, since Dolphin makes it quite easy:
- Write your messages to stderr. For example:
fprintf(stderr, "%s:%d Hello!\n", __func__, __LINE__);. Or use a macro, like those I have in bt-embedded. - Near the beginning of your
main(), call "SYS_STDIO_Report(false);": this instructs libogc to redirect all the stderr to Dolphin's OSReport log type (setting the parameter to "true" will also send the stdout to the log; but at least for console applications, this is something you probably don't want to do). - In Dolphin, enable the
OSREPORTlog type, and disableOSREPORT_HLE(otherwise this will capture stdout too; which is better done by calling "SYS_STDIO_Report(true)"), as shown in the image below:

If you follow this setup, you'll see all the stderr in Dolphin's logs, and the stdout (if you have any) will continue to be shown on the application's console, if you did set up one.
On a real Wii/GameCube
Unless you have an USB Gecko device (which I don't have), your choices are limited to sending the messages to the screen or logging them into a file on the SD card. Here's how:
- As above, write your messages to stderr.
- If you want to see them on the screen, I recommend using my gxconsole library, which can be setup by just calling three functions, plus one more call to draw its contents:
GxConsole *console = gx_console_new(60, 20, &font_cozette_6x13); gx_console_set_input(console, 2); /* The file descriptor to capture (2 = stderr) */ gx_console_set_alpha(console, 128); /* Set 50% transparency */ /* Then, inside the application loop: */ while (app_running) { ... gx_console_draw(console, pos_x, pos_y); ...
- If, instead, you want to capture the messages to a file, you'll need to install a handler for the write operation of your file descriptor:
#include <sys/iosupport.h> static int s_log_fd = -1; static ssize_t stderr_write(struct _reent *r, void *fd, const char *ptr, size_t len) { return write(s_log_fd, ptr, len); } static devoptab_t s_log_dotab = { .name = "log-to-file", .structSize = sizeof(devoptab_t), .write_r = stderr_write, }; static void log_file_open() { fatInitDefault(); s_log_fd = open("my-application.log", O_CREAT | O_TRUNC | O_WRONLY, 0666); devoptab_list[STD_ERR] = &s_log_dotab; } static void log_file_close() { if (s_log_fd >= 0) { fsync(s_log_fd); close(s_log_fd); } } int main(int argc, char **argv) { log_file_open(); fprintf(stderr, "%s:%d Hello, world!\n", __func__, __LINE__); ... the rest of your program... log_file_close(); return EXIT_SUCCESS; }
Note that showing the messages on the screen or writing them into a file is considerably slower than sending them to Dolphin's log, so this methods can slow down your application quite a lot.
Hope this helps!
