<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Allegro 5 Static link crash...? OpenGL is cause?</title>
		<link>http://www.allegro.cc/forums/view/605692</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Wed, 22 Dec 2010 02:24:51 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>For literally YEARS I&#39;ve never succeeded in compiling Allegro 4, WIP or now 5 RC1 statically.<br />All examples crash and nothing works. <br />I&#39;ve posted about this before, and I was told it&#39;s likely that one of the static libs I&#39;m linking with is corrupt.</p><p>I did a lot of testing and now I know what is causing it, but not why it&#39;s happening.</p><p>I re-setup my compiler, (Code::blocks IDE with MinGW, the latter was installed from it&#39;s mingw-get downloader) and all libraries, etc were fresh and new, but this problem still occurs. <br />I wonder if anyone has succeeded in using Allegro 5 statically at all, as here&#39;s the cause:</p><p>It&#39;s OpenGL. If you include it in cmake config, then all examples crash if they use it or not. (it made me have to exclude primatives addon as well as it referenced opengl stuff though in the source it seems to try not to if opengl isn&#39;t used..)<br />As soon as you remove OpenGL from the mix, then all static linking works and no crashes. Add support for OpenGL (WANT_OPENGL in cmake gui checked) and once again every single example crashes before they even make a window, regardless of if they use it or not. (even direct3d example crashes)</p><p>I&#39;m assuming the problem lies in libopengl32.a and the static opengl related libraries themselves? (when using DLLs, it all works fine) a fresh install of MinGW replaced them with new copies, but still nothing solves this problem.... </p><p>I want to use OpenGL for my programs so It&#39;s needed for me.</p><p>I also noticed that memory usage is much better with such:<br />A project of mine that showed to use 38-40MB of ram with 4.9.x<br />now only uses 16MB with OpenGL and 48-60MB with DirectX9 with Allegro 5 RC1
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Mallie)</author>
		<pubDate>Thu, 02 Dec 2010 20:56:30 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>[About static, I never use static linking for several reasons, so no idea.]</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/605692/892799#target">Mallie</a> said:</div><div class="quote"><p>
I also noticed that memory usage is much better with such:<br />A project of mine that showed to use 38-40MB of ram with 4.9.x<br />now only uses 16MB with OpenGL and 48-60MB with DirectX9 with Allegro 5 RC1
</p></div></div><p>

How did you measure that? Most of the used memory usually will be textures and you can get the size of them just by knowing how many bitmaps you create anod how big they are. It sounds to me like that size somehow is hidden with OpenGL, with the way you measure memory. Maybe glTexImage2D(...) allocates the memory in some non-standard way or something.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Thu, 02 Dec 2010 21:20:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I was using the task manager/Resource Monitor in Windows 7 Ultimate.<br />I could be wrong...it shows 27MB now. Probably not a very good thing to use to measure it. Maybe it&#39;s wrong about cpu usage as well; I find that&#39;s returned and the more TTF text is on the screen the worse it gets, also with loading a bunch of images in succession for an animation (unless they&#39;re really small)...(all of this only under windows AFAIK) I should probably ask about those issues in seperate threads as not to get too off topic.</p><p>The reason why I want to use static is so I don&#39;t have like 10+ DLLs all over the place. This was especially difficult/messy for non programmers testing my programs.<br />It works well in Linux/Mac OS X, but not Windows...If I were to guess, I think it&#39;s surely a problem with the static OpenGL libs...or at least the ones provided with MinGW...I wonder what would happen if I tried such with a different compiler, etc...</p><p>At worst case, I guess I could always use something like Inno Setup, etc and make an installer, copying the DLLs to the user&#39;s system folders, which would be pretty nice actually.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Mallie)</author>
		<pubDate>Thu, 02 Dec 2010 22:19:14 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>There&#39;s some sort of issue with linking on older versions of MinGW. I don&#39;t remember the details and I don&#39;t remember whether the problem was with static or dynamic linking.<br />I think Trent mentioned it a couple of times in discussions on the forum.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Thu, 02 Dec 2010 22:45:27 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Assume you&#39;re using MinGW GCC 4.5.0. To compile Allegro as static library with static run-time libraries use following switches:
</p><pre>
Switches for source files:
-s -DALLEGRO_SRC -DALLEGRO_STATICLINK -DALLEGRO_LIB_BUILD

Switches for linker:
-lgcc_eh -static-libgcc -static-libstdc++
</pre><p>

Switches for executable:
</p><pre>
Switches for source files:
-s -DALLEGRO_STATICLINK

Switches for linker:
-lgcc_eh -static-libgcc -static-libstdc++

Libraries:

Allegro and add-ons (list all your application, you may list all they will be ignored if not used):
allegro-5.1.0-static-mt
allegro_audio-5.1.0-static-mt
...

Direct dependencies (libraries used by Allegro):
libFLAC-1.2.1-static-mt
libvorbisfile-1.2.3-static-mt
libvorbis-1.2.3-static-mt
libogg-1.1.4-static-mt
dumb-0.9.3-static-mt
zlib-1.2.5-static-mt
physfs-2.0.0-static-mt
freetype-2.4.2-static-mt

Indirect dependencies (DLL&#39;s availabe in system):
gdiplus
uuid
kernel32
winmm
psapi
opengl32
glu32
user32
comdlg32
gdi32
shell32
ole32
advapi32
ws2_32
</pre><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Michał Cichoń)</author>
		<pubDate>Fri, 03 Dec 2010 03:37:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>gcc 4.5.0 (maybe 4.4) on Windows is the oldest one that is able to build Allegro statically.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trent Gamblin)</author>
		<pubDate>Fri, 03 Dec 2010 06:27:06 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>GCC 4.4.0 is in fact first version which is able to do the job. This is tricky, because MinGW team do not keep the consistency with old releases. You have to manually force linking to the static run-time.<br />TDM GCC releases are better IMHO, because they are prepared to build standalone executables. You have to force shared run-time if you want, because defaults settings follow old MinGW spirit.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Michał Cichoń)</author>
		<pubDate>Fri, 03 Dec 2010 15:33:57 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yeah that&#39;s the version I&#39;m using. GCC 4.5.0.</p><p>@Michał Cichoń:<br />I&#39;m not too sure how to use that info...I&#39;m using CMake GUI to build allegro.<br />I&#39;m not even sure how to set linker options etc for cmake, command line or not. I thought allegro decides on that based on the cmake settings you can change.</p><p>TDM GCC releases?</p><p>EDIT: ooo I&#39;m blind. u see CXX flags/linker settings in cmake. do i just add to it whats not there? </p><p>EDIT 2: I added -lgcc_eh -static-libgcc -static-libstdc++ to CMAKE_EXE_LINKER_FLAGS<br />but now it bugs about redefinition of std::string stuff etc when making exes of demo/examples etc...I&#39;m not sure how to do this right...<br />The libraries produced do make an exe for my own stuff, but same crash at application startup unless opengl is removed
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Mallie)</author>
		<pubDate>Sat, 04 Dec 2010 19:51:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Please use &lt;quote&gt; for quoting.</p><p>Did you rebuild everything? I mean Allegro, all statically linked libraries and your application.</p><p>If only OpenGL is your problem, verify if it is installed correctly. Under Windows check if your GFX driver is installed correctly. If not, Windows provide you OpenGL 1.2 which is to old for Allegro to use.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Michał Cichoń)</author>
		<pubDate>Sun, 05 Dec 2010 19:44:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/605692/893275#target">Michał Cichoń</a> said:</div><div class="quote"><p>
Please use quote for quoting.</p><p>Did you rebuild everything? I mean Allegro, all statically linked libraries and your application.</p><p>If only OpenGL is your problem, verify if it is installed correctly. Under Windows check if your GFX driver is installed correctly. If not, Windows provide you OpenGL 1.2 which is to old for Allegro to use.
</p></div></div><p>

Yes, I did. Everything was done from scratch. Everything else works except OpenGL. When I compile Allegro without OpenGL support then everything works as static.<br />That&#39;s why I was wondering if it&#39;s the OpenGL libraries that come with MinGW causing the problem or something. I redid my whole compiler, MinGW, etc setup and as my Windows 7 install died just recently, I reinstalled everything and up to date GFX driver but still no good..<br />Is there even a way to update OpenGL?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Mallie)</author>
		<pubDate>Mon, 06 Dec 2010 17:59:45 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You will need to grab intel&#39;s latest driver package and see if that helps at all. Otherwise you&#39;re stuck with Microsoft&#39;s broken OpenGL.</p><p>If that doesn&#39;t work, intel&#39;s OpenGL drivers are known to be somewhat lacking.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 06 Dec 2010 18:01:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/605692/893375#target">Thomas Fjellstrom</a> said:</div><div class="quote"><p>
You will need to grab intel&#39;s latest driver package and see if that helps at all. Otherwise you&#39;re stuck with Microsoft&#39;s broken OpenGL.</p><p>If that doesn&#39;t work, intel&#39;s OpenGL drivers are known to be somewhat lacking.
</p></div></div><p>

Ahh, ok. Where might I find that? I assume I can just search &quot;intel&#39;s opengl drivers&quot; I guess; I&#39;ll give that a try.</p><p>I think it&#39;s really silly, tbh...I heard about OpenGL being ended at 1.2 and about<br />how they had to add extensions and all that stuff, though I didn&#39;t really read all that much about it. </p><p>EDIT: All I seem to find is drivers for intel onboard gfx...my card is a nVidia GeForce 8800GT..
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Mallie)</author>
		<pubDate>Mon, 06 Dec 2010 18:17:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/605692/893377#target">Mallie</a> said:</div><div class="quote"><p>Ahh, ok. Where might I find that? I assume I can just search &quot;intel&#39;s opengl drivers&quot; I guess; I&#39;ll give that a try.</p></div></div><p>Sorry, I was being unclear, I don&#39;t think there are separate drivers for OpenGL. Just the regular Graphics drivers should include the OpenGL support.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>I think it&#39;s really silly, tbh...I heard about OpenGL being ended at 1.2 and about<br />how they had to add extensions and all that stuff, though I didn&#39;t really read all that much about it.</p></div></div><p>Well OpenGL development did seem to stall a couple times. But its now up to OpenGL 4.x, so it definitely hasn&#39;t stopped at 1.2. OpenGL 2 was released in 2004, about 7 years ago.</p><p>append:</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>EDIT: All I seem to find is drivers for intel onboard gfx...my card is a nVidia GeForce 8800GT.</p></div></div><p>My bad. I seem to have gotten the impression that you had an Intel IGP (Integrated Graphics Processor). If you have a Gforce, just grab the latest NVidia drivers, and it should support OpenGL 4 by now. And with that card, it WILL have proper FBO support.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 06 Dec 2010 18:21:02 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yeah I sorta thought that too. </p><p>I used this glview program I found to check my openGL support and it says my nVidia drivers support up to OpenGL 3.2...<br />It doesn&#39;t look like an OpenGL support issue at this rate...maybe the OGL libraries that come with MinGW are only 1.2 compliant?? (like libopengl32.a, glu32.a or whatever they called)
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Mallie)</author>
		<pubDate>Mon, 06 Dec 2010 19:01:55 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/605692/893380#target">Mallie</a> said:</div><div class="quote"><p>It doesn&#39;t look like an OpenGL support issue at this rate...maybe the OGL libraries that come with MinGW are only 1.2 compliant?? (like libopengl32.a, glu32.a or whatever they called)</p></div></div><p>libopengl32.a should only be a link library, that is its just there so mingw knows how to link to OpenGL32.dll. If glview is showing 3.2, allegro should be as well.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 06 Dec 2010 19:18:23 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Huh....yeah that&#39;s what I kinda thought....because since OpenGL and those kinda dependancies are rather a given on Windows systems or especially with Mac/Linux ....there would be no need.<br />I dunno...this issue has really stumped me. It&#39;s only windows with the problems I been having as well as the cpu usage issue suddenly returning or being so on things that really shouldn&#39;t be that hard. (ports to mac and linux show no issues at all)</p><p>Kinda frustrating because I finished my project after 7 months and just before release....it&#39;s not a total loss if I have to saay make an installer with the DLLs thats a good workaround if nothing more can be done.</p><p>Still gonna post about those 2 other issues as well but just trying everything I can myself first.</p><p>I wonder if anyone has got Allegro 5 to statically link with OpenGL use...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Mallie)</author>
		<pubDate>Mon, 06 Dec 2010 19:34:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>As far as I know, you can&#39;t statically link with OpenGL. Much like you can&#39;t statically link with core windows dlls. But then I don&#39;t think theres a real static opengl lib, so it shouldn&#39;t be a problem.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 06 Dec 2010 19:45:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yeah..</p><p>I believe I&#39;ve had this same problem on multiple computers as well.<br />It seems that Allegro 5 actually doesn&#39;t work statically, unless using DirectX.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Mallie)</author>
		<pubDate>Tue, 07 Dec 2010 01:44:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>In attachment you can find test_driver compiled with MinGW GCC 4.5.0. Everything is linked statically so there is one and only executable without any additional dependencies.<br />I prepared for you a short test. You will find two files <span class="source-code">do_test_gl.bat</span> and <span class="source-code">do_test_gl_1_2.bat</span>. They launch primitive test, first force any OpenGL version, second force OpenGL 1.2.<br />If they do not work, that&#39;s mean you have something wrong with your OpenGL libraries. Otherwise you&#39;re doing something wrong while preparing your own executable.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Michał Cichoń)</author>
		<pubDate>Tue, 07 Dec 2010 14:53:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/605692/893504#target">Michał Cichoń</a> said:</div><div class="quote"><p>
In attachment you can find test_driver compiled with MinGW GCC 4.5.0. Everything is linked statically so there is one and only executable without any additional dependencies.<br />I prepared for you a short test. You will find two files do_test_gl.bat and do_test_gl_1_2.bat. They launch primitive test, first force any OpenGL version, second force OpenGL 1.2.<br />If they do not work, that&#39;s mean you have something wrong with your OpenGL libraries. Otherwise you&#39;re doing something wrong while preparing your own executable.
</p></div></div><p>

I tried the test and it was working. It showed stuff and wrote results to result.txt<br />I guess I just don&#39;t know how to prepare executable. The allegro examples don&#39;t work,(I think the resulting libraries don&#39;t ether) nor does compiling my own executables; they compile, etc but crash when run.<br />I tried following the list you gave me before but made no difference.<br />except I had no idea where to put <br />-s -DALLEGRO_SRC -DALLEGRO_STATICLINK -DALLEGRO_LIB_BUILD<br />in cmake gui and it does know to make static from the shared flag.</p><p>moreover, I dunno why things named &#39;-static-mt&#39; in such because my libraries etc have no names like that. (I know what it means but it&#39;s not naming them that way) </p><p>EDIT: I notice -DALLEGRO_SRC -DALLEGRO_STATICLINK -DALLEGRO_LIB_BUILD these don&#39;t seem to exist? for example -DALLEGRO_STATICLINK is actually -DSHARED and such is all whats listed in cmake GUI.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Mallie)</author>
		<pubDate>Wed, 08 Dec 2010 10:13:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/605692/893695#target">Mallie</a> said:</div><div class="quote"><p>EDIT: I notice -DALLEGRO_SRC -DALLEGRO_STATICLINK -DALLEGRO_LIB_BUILD these don&#39;t seem to exist? for example -DALLEGRO_STATICLINK</p></div></div><p>Those aren&#39;t CMAKE flags, rather defines for the compiler. Also ALLEGRO_LIB_BUILD and ALLEGRO_SRC are NOT to be used for anything but the allegro library itself. You do however need to set ALLEGRO_STATICLINK when statically linking to allegro in your own programs. It needs to be set before you include any allegro headers. Either using a gcc -D flag, or <span class="source-code"><span class="p">#define FOO</span></span> before the <span class="source-code"><span class="p">#include</span></span> lines for allegro.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Wed, 08 Dec 2010 13:56:55 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It has named that way, because my build system use such postfix to differentiate between different compiler/lib configurations. You may try precompiled binaries availabla at <a href="http://allegro5.org/">http://allegro5.org/</a>.</p><p>That way you will be able to use Allegro without problems. You will need those with &quot;-static-mt-&quot;  suffix, which mean Allegro is compiled as static library and use statically linked run-time libraries.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Michał Cichoń)</author>
		<pubDate>Wed, 08 Dec 2010 23:36:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>OoooO! I didn&#39;t know that static binaries were available! Always saw &#39;em as DLLs. <br />I&#39;m going to give this a try! Hopefully it fixes my issue. I&#39;ll post back if I have any problems. </p><p>EDIT: YES!! It&#39;s working!! <img src="http://www.allegro.cc/forums/smileys/cheesy.gif" alt=":D" /> YAY!<br />I noticed I had to link with flac and dumb libs tho i don&#39;t use them. flac gave me a problem an undefined ref to ntoh@14 or something....but I used the copy I had and then it was ok. When I ran my visual novel interpreter, it started up no problem and everything worked! Except the rain from thunderstorm was black and other such things. That&#39;s the premultiplied alpha stuff of 5.0.0 RC1/RC2 I&#39;m assuming. maybe I&#39;ll use that flag that shuts it off or else modify to support it. </p><p>Thanks SO much for your help!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Mallie)</author>
		<pubDate>Thu, 09 Dec 2010 01:15:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You&#39;re welcome.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Michał Cichoń)</author>
		<pubDate>Thu, 09 Dec 2010 04:52:20 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Are there prebuilt static binaries for MinGW <i>gcc</i> 4.4.0?.</p><p>It&#39;s the first time I&#39;m dealing with static linking and I&#39;m having the same problems as Mallie. I usually build the shared libs with <i>gcc</i> 3.4.5 but now I wanted to send a single exe and it seems Mallie had luck using the prebuilt libraries.</p><p>As Mallie, I built Allegro and can get my program to compile but it crashes. The MinGW 4.4.0 binaries here at <i>allegro.cc</i> don&#39;t include the static libraries and since <i>allegro5.org</i> now redirects to the Allegro homepage I&#39;m wondering if there are static binaries for 4.4.0 or if they&#39;re only available for <i>gcc</i> 4.5.0.</p><p>Thanks.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (kenmasters1976)</author>
		<pubDate>Wed, 22 Dec 2010 01:15:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yes, check out <a href="http://www.allegro.cc/files/">http://www.allegro.cc/files/</a>.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Michał Cichoń)</author>
		<pubDate>Wed, 22 Dec 2010 02:19:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>No, that&#39;s the point of my post. The 4.4.0 pack does not include the static version of the Allegro libraries. The 4.5.0 pack does but as I have a MinGW with <i>gcc</i> 4.4.0 all set I was trying to use it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (kenmasters1976)</author>
		<pubDate>Wed, 22 Dec 2010 02:24:51 +0000</pubDate>
	</item>
</rss>
