<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>SDL-Wii: undefined reference to main</title>
<description> Every single time I link SDL-Wii into one of my programs, I get the following error:

c:/devkitpro/devkitppc/bin/../lib/gcc/powerpc-eabi/4.4.1/../../../../powerpc-eabi/lib/crtmain.o: In function `__crtmain&amp;#039;:
e:/devkitpro-svn/buildscripts/newlib-1.17.1/libgloss/rs6000/crtmain.c:18: undefined reference to `main&amp;#039;
collect2: ld returned 1 exit status

I was told on the IRC awhile ago that updating to svn libogc and devkitPPC would fix the problem. I finally did, but they didn&amp;#039;t fix the problem. This leads to believe that I misusing SDL-Wii.

Suggestions?</description><link>http://forum.wiibrew.org/read.php?11,36564,36564#msg-36564</link><lastBuildDate>Wed, 22 Apr 2026 04:15:39 +0200</lastBuildDate>
<generator>Phorum 5.2.23</generator>
<item>
<guid>http://forum.wiibrew.org/read.php?11,36564,40278#msg-40278</guid>
<title>Re: SDL-Wii: undefined reference to main</title><link>http://forum.wiibrew.org/read.php?11,36564,40278#msg-40278</link><description><![CDATA[ Could you please tell me where I could find it?]]></description>
<dc:creator>Arikado</dc:creator>
<category>Coding</category><pubDate>Fri, 06 Nov 2009 12:49:00 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,36564,40258#msg-40258</guid>
<title>Re: SDL-Wii: undefined reference to main</title><link>http://forum.wiibrew.org/read.php?11,36564,40258#msg-40258</link><description><![CDATA[ dhewg has written some console code that works in GX, I would suggest using that.]]></description>
<dc:creator>Tantric</dc:creator>
<category>Coding</category><pubDate>Fri, 06 Nov 2009 04:36:32 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,36564,40246#msg-40246</guid>
<title>Re: SDL-Wii: undefined reference to main</title><link>http://forum.wiibrew.org/read.php?11,36564,40246#msg-40246</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>Tantric</strong><br />Setting up a console would be pointless as it&#039;s not visible with GX enabled.</div></blockquote>
scanff and I had a discussion on IRC and I realize that now.<br /><br />Tantric, one of the projects I&#039;m developing is giving me a lot of trouble and I&#039;d like to print text on the screen to be able to debug where the crash occurs. So my question to you is, how would you recommend printing text to the screen in a program which uses SDL?]]></description>
<dc:creator>Arikado</dc:creator>
<category>Coding</category><pubDate>Fri, 06 Nov 2009 02:48:27 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,36564,40237#msg-40237</guid>
<title>Re: SDL-Wii: undefined reference to main</title><link>http://forum.wiibrew.org/read.php?11,36564,40237#msg-40237</link><description><![CDATA[ Setting up a console would be pointless as it&#039;s not visible with GX enabled.]]></description>
<dc:creator>Tantric</dc:creator>
<category>Coding</category><pubDate>Fri, 06 Nov 2009 01:35:09 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,36564,40236#msg-40236</guid>
<title>Re: SDL-Wii: undefined reference to main</title><link>http://forum.wiibrew.org/read.php?11,36564,40236#msg-40236</link><description><![CDATA[ No, it does not set up a console.]]></description>
<dc:creator>jendave</dc:creator>
<category>Coding</category><pubDate>Fri, 06 Nov 2009 01:04:56 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,36564,40228#msg-40228</guid>
<title>Re: SDL-Wii: undefined reference to main</title><link>http://forum.wiibrew.org/read.php?11,36564,40228#msg-40228</link><description><![CDATA[ Thank-you scanff. You are very helpful :-)<br /><br />Does it set-up a console? It appears not to?]]></description>
<dc:creator>Arikado</dc:creator>
<category>Coding</category><pubDate>Thu, 05 Nov 2009 23:11:42 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,36564,40225#msg-40225</guid>
<title>Re: SDL-Wii: undefined reference to main</title><link>http://forum.wiibrew.org/read.php?11,36564,40225#msg-40225</link><description><![CDATA[ It&#039;s an internal function in SDL_wiivideo.c:<br /><pre class="bbcode">
void
WII_InitVideoSystem()
{
	/* Initialise the video system */
	VIDEO_Init();
	vmode = VIDEO_GetPreferredMode(NULL);

	switch (vmode-&gt;viTVMode &gt;&gt; 2)
	{
		case VI_PAL: // 576 lines (PAL 50hz)
			// display should be centered vertically (borders)
			vmode = &TVPal574IntDfScale;
			vmode-&gt;xfbHeight = 480;
			vmode-&gt;viYOrigin = (VI_MAX_HEIGHT_PAL - 480)/2;
			vmode-&gt;viHeight = 480;
			break;

		case VI_NTSC: // 480 lines (NTSC 60hz)
			break;

		default: // 480 lines (PAL 60Hz)
			break;
	}

	/* Set up the video system with the chosen mode */
	VIDEO_Configure(vmode);

	// Allocate the video buffers
	xfb[0] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));
	xfb[1] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));

	VIDEO_ClearFrameBuffer(vmode, xfb[0], COLOR_BLACK);
	VIDEO_ClearFrameBuffer(vmode, xfb[1], COLOR_BLACK);
	VIDEO_SetNextFramebuffer (xfb[0]);

	// Show the screen.
	VIDEO_SetBlack(FALSE);
	VIDEO_Flush();
	VIDEO_WaitVSync();
	if (vmode-&gt;viTVMode & VI_NON_INTERLACE)
			VIDEO_WaitVSync();
		else
			while (VIDEO_GetNextField())
				VIDEO_WaitVSync();

	/*** Clear out FIFO area ***/
	memset (&gp_fifo, 0, DEFAULT_FIFO_SIZE);

	/*** Initialise GX ***/
	GX_Init (&gp_fifo, DEFAULT_FIFO_SIZE);

	GXColor background = { 0, 0, 0, 0xff };
	GX_SetCopyClear (background, 0x00ffffff);

	SetupGX();
}

</pre>]]></description>
<dc:creator>scanff</dc:creator>
<category>Coding</category><pubDate>Thu, 05 Nov 2009 22:51:36 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,36564,40221#msg-40221</guid>
<title>Re: SDL-Wii: undefined reference to main</title><link>http://forum.wiibrew.org/read.php?11,36564,40221#msg-40221</link><description><![CDATA[ What does WII_InitVideoSystem() do as opposed to VIDEO_Init()?]]></description>
<dc:creator>Arikado</dc:creator>
<category>Coding</category><pubDate>Thu, 05 Nov 2009 22:07:21 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,36564,38319#msg-38319</guid>
<title>Re: SDL-Wii: undefined reference to main</title><link>http://forum.wiibrew.org/read.php?11,36564,38319#msg-38319</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>Arikado</strong><br /><blockquote class="bbcode"><div><small>Quote<br /></small><strong>henke37</strong><br />When using sdl, it hijacks the role as main, your main is silently renamed to something else.</div></blockquote>
Now that I&#039;m actually using it, I can see the presence of this. For curiosity&#039;s sake, do you know what code is actually executed first then? When does my program reach to the point of executing the first line of code in my main() ?</div></blockquote><br />for the Wii it&#039;s<br /><br /><pre class="bbcode">
/* Do initialisation which has to be done first for the console to work */
/* Entry point */
int main(int argc, char *argv[])
{
#ifdef HW_RVL
	// Wii Power/Reset buttons
	WPAD_Init();
	WPAD_SetPowerButtonCallback((WPADShutdownCallback)ShutdownCB);
	SYS_SetPowerCallback(ShutdownCB);
	SYS_SetResetCallback(ResetCB);
#endif
	PAD_Init();
	WII_InitVideoSystem();
#ifdef HW_RVL
	WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
	WPAD_SetVRes(WPAD_CHAN_ALL, 640, 480);

	MOUSE_Init();
	KEYBOARD_Init(NULL);
#endif
	/* Call the user&#039;s main function */
	return(SDL_main(argc, argv));
}

</pre>]]></description>
<dc:creator>scanff</dc:creator>
<category>Coding</category><pubDate>Sat, 17 Oct 2009 22:09:29 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,36564,38295#msg-38295</guid>
<title>Re: SDL-Wii: undefined reference to main</title><link>http://forum.wiibrew.org/read.php?11,36564,38295#msg-38295</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>henke37</strong><br />When using sdl, it hijacks the role as main, your main is silently renamed to something else.</div></blockquote>
Now that I&#039;m actually using it, I can see the presence of this. For curiosity&#039;s sake, do you know what code is actually executed first then? When does my program reach to the point of executing the first line of code in my main() ?]]></description>
<dc:creator>Arikado</dc:creator>
<category>Coding</category><pubDate>Sat, 17 Oct 2009 19:59:47 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,36564,37308#msg-37308</guid>
<title>Re: SDL-Wii: undefined reference to main</title><link>http://forum.wiibrew.org/read.php?11,36564,37308#msg-37308</link><description><![CDATA[ Thanks - worked :-)]]></description>
<dc:creator>Arikado</dc:creator>
<category>Coding</category><pubDate>Fri, 09 Oct 2009 22:57:06 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,36564,36692#msg-36692</guid>
<title>Re: SDL-Wii: undefined reference to main</title><link>http://forum.wiibrew.org/read.php?11,36564,36692#msg-36692</link><description><![CDATA[ When using sdl, it hijacks the role as main, your main is silently renamed to something else.]]></description>
<dc:creator>henke37</dc:creator>
<category>Coding</category><pubDate>Mon, 05 Oct 2009 07:15:06 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,36564,36639#msg-36639</guid>
<title>Re: SDL-Wii: undefined reference to main</title><link>http://forum.wiibrew.org/read.php?11,36564,36639#msg-36639</link><description><![CDATA[ Hummm.... I had this issue once, I&#039;m trying to remember how I fixed it. Try a couple of things :<br /><br />- Check the link order of the libraries ( I think the correct order is on the SDL Wiki page)<br />- Make sure that your main function is the same prototype as SDL main. (What I use is int main(int argc, char **argv)).]]></description>
<dc:creator>scanff</dc:creator>
<category>Coding</category><pubDate>Sun, 04 Oct 2009 21:37:51 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,36564,36564#msg-36564</guid>
<title>SDL-Wii: undefined reference to main</title><link>http://forum.wiibrew.org/read.php?11,36564,36564#msg-36564</link><description><![CDATA[ Every single time I link SDL-Wii into one of my programs, I get the following error:<br /><pre class="bbcode">
c:/devkitpro/devkitppc/bin/../lib/gcc/powerpc-eabi/4.4.1/../../../../powerpc-eabi/lib/crtmain.o: In function `__crtmain&#039;:
e:/devkitpro-svn/buildscripts/newlib-1.17.1/libgloss/rs6000/crtmain.c:18: undefined reference to `main&#039;
collect2: ld returned 1 exit status</pre><br />I was told on the IRC awhile ago that updating to svn libogc and devkitPPC would fix the problem. I finally did, but they didn&#039;t fix the problem. This leads to believe that I misusing SDL-Wii.<br /><br />Suggestions?]]></description>
<dc:creator>Arikado</dc:creator>
<category>Coding</category><pubDate>Sun, 04 Oct 2009 16:07:43 +0200</pubDate></item>
</channel>
</rss>