<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>[A4] undefined reference to `WinMain@16&#39; ONLY in Debug mode</title>
		<link>http://www.allegro.cc/forums/view/606515</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Fri, 25 Feb 2011 00:53:47 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I recently started work on an old game which works, but has a bug I am trying to track down.</p><p>I&#39;m using Allegro 4 with MinGW and CodeBlocks.</p><p>I enabled debug mode, linked the appropriate alleg44-debug etc... the game compiles up just fine in normal (release) mode, but when I tell CodeBlocks to compile it in debug mode I get this error.  I know normally this means I&#39;m missing END_OF_MAIN() but in this case I am not.  I would post my code but there is FAR too much of it.</p><p>the end of my main looks like:</p><div class="source-code snippet"><div class="inner"><pre><span class="k2">}</span>
<a href="http://www.allegro.cc/manual/END_OF_MAIN"><span class="a">END_OF_MAIN</span></a><span class="k2">(</span><span class="k2">)</span>
</pre></div></div><p>

like I said, it compiles and runs fine when not in debug mode.  The only difference between release and debug is it links the allegro debug library and I enable debug symbols.  Otherwise, the rest of the settings are the same.</p><p>Strange error, I didn&#39;t want to work on this again in the first place, but the bug causes my game to freeze up totally and I have to use task manager to shut it down, so I need to use debug mode and track this if possible. &lt;sigh&gt;</p><p>Any help would be appreciated.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Roy)</author>
		<pubDate>Fri, 25 Feb 2011 00:16:26 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Make sure the debug profile is also using the /subsystem:windows linker option.</p><p>Edit: that&#39;s for MSVC. Similar thing might apply to you.</p><p>Edit 2: Actually that doesn&#39;t make any sense since it is looking for WinMain but cannot find it.</p><p>The related things would be:</p><ul><li><p>END_OF_MAIN() isn&#39;t used (it should be)
</p></li><li><p>ALLEGRO_USE_CONSOLE is defined (it shouldn&#39;t be)
</p></li><li><p>ALLEGRO_NO_MAGIC_MAIN is defined (it shouldn&#39;t be)
</p></li></ul></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Fri, 25 Feb 2011 00:17:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>the MinGW32 command is &quot;--subsystem,windows&quot; by the way, didn&#39;t help, but could be useful to know in the future.</p><p>I have END_OF_MAIN() properly, I don&#39;t use those other two.  Like I said, it compiles just fine in release mode, but when I switch to debug mode I get that.  Doesn&#39;t make any sense at all. </p><p>I&#39;ll keep at it and let you know if I come up with something...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Roy)</author>
		<pubDate>Fri, 25 Feb 2011 00:33:44 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You can easily see if it&#39;s an END_OF_MAIN problem by just hardcoding it:
</p><div class="source-code snippet"><div class="inner"><pre>      <span class="k1">int</span> __stdcall WinMain<span class="k2">(</span><span class="k1">void</span> <span class="k3">*</span>hInst, <span class="k1">void</span> <span class="k3">*</span>hPrev, <span class="k1">char</span> <span class="k3">*</span>Cmd, <span class="k1">int</span> nShow<span class="k2">)</span>  
      <span class="k2">{</span>                                                                      
         <span class="k1">return</span> _WinMain<span class="k2">(</span><span class="k2">(</span><span class="k1">void</span> <span class="k3">*</span><span class="k2">)</span>_mangled_main, hInst, hPrev, Cmd, nShow<span class="k2">)</span><span class="k2">;</span>   
      <span class="k2">}</span>
</pre></div></div><p>
Requires you to rename your &quot;main&quot; function to &quot;_mangled_main&quot;.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Fri, 25 Feb 2011 00:42:13 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Why would that be an END_OF_MAIN() problem if it compiles just fine when not in debug mode though?  If it was an END_OF_MAIN() problem it should give me the same error regardless of which mode I compile it for.</p><p>I&#39;ll try that out, but I&#39;m certain that is not the problem.</p><p>Same error... here&#39;s the exact error, perhaps this will shine more light on the problem:</p><p>c:\users\neil\develop\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libmingw32.a(main.o):main.c|| undefined reference to `WinMain@16&#39;|</p><p>Wait a sec... I think I see the problem... where in hell is it getting a main.c from???  I don&#39;t have a main.c in my project.  &gt;=(  &lt;bangs head against wall&gt;</p><p>EDIT: okay, I solved the problem by deleting the DEBUG build options and recreating a new DEBUG build by copying the release version and renaming it DEBUG, then changing a few settings specifically to debugging and it works.  I originally just created a debug build then done all the settings.  Although they all LOOKED correct, obviously something was amiss... who knows... strange and I wish I knew what it was, but it works anyhow.  It was some screwy compiler setting...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Roy)</author>
		<pubDate>Fri, 25 Feb 2011 00:53:47 +0000</pubDate>
	</item>
</rss>
