Cygon
02-08-2011 09:24:35
Over the weekend, I've done some builds of Mogre with Ogre 1.7.3 targeting x64. I also decided to build all dependencies from scratch to achieve a homogenous build, so I'm now using Boost 1.47.0, FreeImage 3.15.1 and CG 3.0.
Everything seems to be working fine, except for one thing: when I load Ogre's OpenGL driver, I get a crash during shutdown in Boost -> run_thread_exit_callbacks() (thread.cpp).
This happens with the x86 build and the x64 build equally (same behavior, same reproduction, same crash site), so I don't think it's an x64-specific problem. On the other hand, I think vanilla Mogre uses statically linked Boost libraries, whereas I use a hand-compiled DLL version (containing only Boost.Thread, Boost.Date_Time and Boost.Regex).
Basically, I just wanted to ask -- has anyone here ever attempted using Boost in a DLL? Did it work?
EDIT: The issue has since been tracked down, it's because Mogre.Root.Shutdown() is being called by .NET's GC thread and Ogre's OpenGL RenderSystem can't handle a shutdown from a different thread currently. Currentl build works around this by moving the shutdown code into the finalizer instead of the destructor. This means you leave resource cleanup to the OS if you don't call Root.Shutdown() when your game terminates. The workaround hopefully won't be necessary for future Ogre releases.
If anyone wants to give it a try:
http://www.nuclex.org/MogreTutorial-1.7.3-VC2010-x86-x64.7z (~55 MiB)
http://www.nuclex.org/MogrePatchesAndSolutions-1.7.3.7z (~140 KiB)
Sorry about the file size, I included the .pdbs of everything so that crashes can be tracked down. Extracted size is about 623 MiB.
NOTES FROM FURTHER POSTS:
-----------------------------------------
You need to copy the dll files from:
.\References\ogre\msvc-10.0-x86\
.\References\mogre\net-4.0-x86\
.\References\freeimage\msvc-10.0-x86\
.\References\tr1boost\msvc-10.0-x86\
.\References\cg\msvc-10.0-x86\ (for Cg)
.\References\mois\net-4.0-x86\ (for Mois)
.\References\ois\msvc-10.0-x86\ (for Mois)
(or 'x64' if you want to use the 64-bit version)
The easiest way to use this Mogre build in a new project would be to just take the "References" and "MogreDependencies" from the example, then add a reference to Mogre.dll and to the MogreDependencies project.
Sidenote: some people just dump such DLLs into the bin\Debug or bin\Release directories by hand, but since the 'bin' directory typically isn't committed to a VCS and everyone downloading a working copy would have to do additional steps then, it's better to add those DLLs as files to the project and use the "Copy to Output Directory" feature. This is what the "MogreDependencies" project in my example does. I used a separate project so I don't clutter up the main project.
The exact dependencies are:
- DirectX June 2010 (I compiled Ogre against the June 2010 DirectX SDK)[/*:m]
- Visual C++ 2010 SP1 runtime (every single binary in this build is compiled with that compiler and uses the DLL runtime)[/*:m]
- An SSE2-capable CPU (I enabled it in all projects since it improves performance and I think all Pentium IIIs and Athlon XPs have been phased out by now)[/*:m][/list:u]
Do I not need anymore Debug or Release versions of the Mogre and Ogre dlls? The same for both configurations?
Use the same for both configurations. [...]
What do I need the "tr1boost.dll" in my execution directory for
It contains the backing code of Boost (date_time, regexp and math). Vanilla Ogre links to Boost as a static library, but then you end up with one additional copy of the Boost code in memory for each Ogre DLL, which I considered wasteful, so I compiled the required parts as a DLL. The "Tr1Boost" name is because it's a minimal subset of Boost, containing only the headers required by Ogre and to support C++ TR1 in Visual C++ 2010 SP1. Only 902 headers instead of 8597 for Boost 1.47
Cygons x64 build is extremely stable under multithreading.