Windows XP support for 1.9 dropped?

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
FuzzyShoting
Kobold
Posts: 28
Joined: Sun Apr 22, 2012 3:34 pm
x 1

Windows XP support for 1.9 dropped?

Post by FuzzyShoting »

http://www.ogre3d.org/forums/viewtopic.php?f=4&t=76985

I grabbed the most recent Ogre from bitbucket. Compiled it on windows 7 64bit, visual studio 2010.
Sent the demos to a friend with XP and was told it gave
The procedure entry point InterlockedCompareExchange64 could not be located in the dynamic link library KERNEL32.dll
Searched through the entire project and all depending libraries and found only _InterlockedCompareExchange64 in OgreAtomicWrappers.h
According to the first mentioned forum thread then this shouldn't happen.
Is there something I missed?
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Windows XP support for 1.9 dropped?

Post by jacmoe »

Compile for 32bit! :)
There is nothing in Ogre AFAIK that 'drops XP'.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
FuzzyShoting
Kobold
Posts: 28
Joined: Sun Apr 22, 2012 3:34 pm
x 1

Re: Windows XP support for 1.9 dropped?

Post by FuzzyShoting »

I see you misunderstood me. My bad!
FuzzyShoting wrote: I grabbed the most recent Ogre from bitbucket. Compiled it on windows 7 64bit, visual studio 2010.
I meant my system is 64bit, but I am compiling 32bit (WIN32)
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Windows XP support for 1.9 dropped?

Post by jacmoe »

It looks like you're not since your compiled application wants to link to a 64-bit library. :)
I am certain that InterlockedCompareExchange64 is 64bit.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
bstone
OGRE Expert User
OGRE Expert User
Posts: 1920
Joined: Sun Feb 19, 2012 9:24 pm
Location: Russia
x 201

Re: Windows XP support for 1.9 dropped?

Post by bstone »

32bit WinAPI has it as well but according to MSDN it exists only in Vista and later Windows versions.
User avatar
sparkprime
Ogre Magi
Posts: 1137
Joined: Mon May 07, 2007 3:43 am
Location: Ossining, New York
x 13
Contact:

Re: Windows XP support for 1.9 dropped?

Post by sparkprime »

I compile my 1-9 based fork on XP 32 bit almost every day and have no problem.
FuzzyShoting
Kobold
Posts: 28
Joined: Sun Apr 22, 2012 3:34 pm
x 1

Re: Windows XP support for 1.9 dropped?

Post by FuzzyShoting »

I have uploaded the demo to http://download.kitopen.com/ogre/ogre1. ... 1e-demo.7z

Could it possibly be something the compiler does? That is replaces _InterlockedCompareExchange64 with InterlockedCompareExchange64 just because it is there
User avatar
sparkprime
Ogre Magi
Posts: 1137
Joined: Mon May 07, 2007 3:43 am
Location: Ossining, New York
x 13
Contact:

Re: Windows XP support for 1.9 dropped?

Post by sparkprime »

Maybe you haven't configured your build to support XP or something?
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Windows XP support for 1.9 dropped?

Post by jacmoe »

Blender fixed the problem:
http://projects.blender.org/tracker/?fu ... group_id=9
Unfortunately, we don't know how. :)
I think the safest bet would be to install XP in a virtual machine and build it there - or use a build bot running XP.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
FuzzyShoting
Kobold
Posts: 28
Joined: Sun Apr 22, 2012 3:34 pm
x 1

Re: Windows XP support for 1.9 dropped?

Post by FuzzyShoting »

In OgreMain Project Properties => Configuration Properties => C/C++ => Optimization is Enable Intrinsic Functions that is set to No on my laptop.
I will need to check with my tower as well tomorrow and then recompile with it set to Yes instead and send it to my friend's xp.

But if it is set to No on my tower then this is likely the reason, since _InterlockedCompareExchange64 is an intrinsic function
FuzzyShoting
Kobold
Posts: 28
Joined: Sun Apr 22, 2012 3:34 pm
x 1

Re: Windows XP support for 1.9 dropped?

Post by FuzzyShoting »

Enabled the intrinsic functions. Still the same error however.
Ogremain.dll didn't increase in size either as the compiler notes said it could do

http://download.kitopen.com/ogre/ogre1. ... ic-demo.7z
FuzzyShoting
Kobold
Posts: 28
Joined: Sun Apr 22, 2012 3:34 pm
x 1

Re: Windows XP support for 1.9 dropped?

Post by FuzzyShoting »

Tracked this down from Ogre
http://www.miikahweb.com/en/blender/svn ... mmit/52232

Not the golden goose I had expected though. But it does seem they provide their own inline asm replacement version of it a few lines above. Maybe I could make use of that.
GarretTheThief
Gnoblar
Posts: 10
Joined: Sun Feb 27, 2011 6:02 am

Re: Windows XP support for 1.9 dropped?

Post by GarretTheThief »

I am also encountering this error. It occurs using the SDK as well as building from the latest source. Just for kicks, I removed the line completely and rebuilt the entire solution. It still comes up with the same error. I found that to be confusing, does anyone know where else that function would be called? I'll try to do some more in depth debugging today.
User avatar
sparkprime
Ogre Magi
Posts: 1137
Joined: Mon May 07, 2007 3:43 am
Location: Ossining, New York
x 13
Contact:

Re: Windows XP support for 1.9 dropped?

Post by sparkprime »

Perhaps it's due to linking in boost? Give all the libraries you're linking (unless they're from the prebuilt ogre dependencies package in which case just say whether you're using that or building your own or whatever)
GarretTheThief
Gnoblar
Posts: 10
Joined: Sun Feb 27, 2011 6:02 am

Re: Windows XP support for 1.9 dropped?

Post by GarretTheThief »

Hmm, it seems CMAKE linked dependencies that were current for OGRE 1.7.2 and boost 1.44. I will update those to the current versions and try again. I can see the hang up occurring when OgreMain.dll is loaded but I haven't looked beyond that.
GarretTheThief
Gnoblar
Posts: 10
Joined: Sun Feb 27, 2011 6:02 am

Re: Windows XP support for 1.9 dropped?

Post by GarretTheThief »

Does not seem to work in any situation. Different builds of boost, the pre-built SDK's OgreMain.dll, multiple XP systems, all getting the same message. I guess I'll have to upgrade to windows 8 to continue developing with 1.9. I even tried replacing the function manually but it still tries to import it.
User avatar
sparkprime
Ogre Magi
Posts: 1137
Joined: Mon May 07, 2007 3:43 am
Location: Ossining, New York
x 13
Contact:

Re: Windows XP support for 1.9 dropped?

Post by sparkprime »

What you're doing differently to me is that you are building on Windows 7 instead of Windows XP. I doubt moving to Windows 8 will help.
GarretTheThief
Gnoblar
Posts: 10
Joined: Sun Feb 27, 2011 6:02 am

Re: Windows XP support for 1.9 dropped?

Post by GarretTheThief »

I'm compiling and running on XP SP3. I don't think moving to 8 will allow the output to run on XP but I will at least be able to get it to work.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Windows XP support for 1.9 dropped?

Post by Kojack »

Have you tried running in release mode?
The _InterlockedCompareExchange64 call is inside of a templated function, it is only used when the template is built on a 64 bit datatype. In a 32bit build of ogre the datatype used in the resource system (which is what uses this code) is only 32 bit, so _InterlockedCompareExchange64 is never called. BUT, in a debug build, all the code is still there, it needs to runtime link with _InterlockedCompareExchange64, _InterlockedCompareExchange and _InterlockedCompareExchange16, even if they aren't used.

In release builds, unused template code is thrown away, no reference to _InterlockedCompareExchange64 should exist if it was never called.

I just tried a release build of the 1.9 demos in an XP virtual machine, it runs fine. Well, it runs slow as hell and I had to disable dx9, but otherwise it's working.
I don't have an actual xp machine to test on, but since this is a dynamic linking problem with the kernel the behaviour in a virtual machine should be the same.
bstone
OGRE Expert User
OGRE Expert User
Posts: 1920
Joined: Sun Feb 19, 2012 9:24 pm
Location: Russia
x 201

Re: Windows XP support for 1.9 dropped?

Post by bstone »

If it's still there in debug builds I doubt that's because of templates. Compiler doesn't instantiate templated code unless it's actually used. The debug/release compiler options do not matter there. Otherwise debug builds would never finish :)
User avatar
sparkprime
Ogre Magi
Posts: 1137
Joined: Mon May 07, 2007 3:43 am
Location: Ossining, New York
x 13
Contact:

Re: Windows XP support for 1.9 dropped?

Post by sparkprime »

Try checking out our svn and running the binary in there -- it's build in an XP VM but I realised I only tested it on Windows 7. I'm not sure if any of our users are still using XP now that I think about it...

http://gritengine.com/download

There is quick start info linked on that page

I should say that this build is against a modified v1-9 but the modifications are not extensive.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Windows XP support for 1.9 dropped?

Post by Kojack »

bstone wrote:If it's still there in debug builds I doubt that's because of templates. Compiler doesn't instantiate templated code unless it's actually used. The debug/release compiler options do not matter there. Otherwise debug builds would never finish :)
In this case the compiler does instantiate templated code that isn't used (check the assembly, it's there).
But it's not template specialisation going on here, it's a series of if commands within the one templated function that check the size of the template parameter. Even though the template is never instantiated on a 64 bit value, the 64 bit value code path still must be present in debug mode. In release it can optimise away the tests to see what size was passed in.

Although looking at the assembly shows that for me it's just doing a lock call anyway, not calling the missing function (guess I have intrinsics on).
bstone
OGRE Expert User
OGRE Expert User
Posts: 1920
Joined: Sun Feb 19, 2012 9:24 pm
Location: Russia
x 201

Re: Windows XP support for 1.9 dropped?

Post by bstone »

Kojack wrote:But it's not template specialisation going on here, it's a series of if commands within the one templated function that check the size of the template parameter.
That's another story then and actually can be reworked into a call of another template function with a size_t template parameter with appropriate specializations. That will solve the issue and make the code more efficient by removing unnecessary branching.
FuzzyShoting
Kobold
Posts: 28
Joined: Sun Apr 22, 2012 3:34 pm
x 1

Re: Windows XP support for 1.9 dropped?

Post by FuzzyShoting »

Blender has this coded in OpenImageIO (blender patches this library)

Code: Select all

...
#if defined(_MSC_VER) && !USE_TBB
#  include <windows.h>
#  include <winbase.h>
#  pragma intrinsic (_InterlockedExchangeAdd)
#  pragma intrinsic (_InterlockedCompareExchange)
#  pragma intrinsic (_InterlockedCompareExchange64)
#  if defined(_WIN64)
#    pragma intrinsic(_InterlockedExchangeAdd64)
#  endif
#endif
...
inline LONGLONG _InterlockedCompareExchange64(LONGLONG volatile* Destination, LONGLONG Exchange, LONGLONG Comperand)
{
	__asm {
		mov esi, [Destination]
		mov ebx, dword ptr [Exchange]
		mov ecx, dword ptr [Exchange + 4]
		mov eax, dword ptr [Comperand]
		mov edx, dword ptr [Comperand + 4]
   		lock cmpxchg8b [esi]
	}
}
Entire file is pasted at http://pastebin.mozilla.org/2382459
User avatar
sparkprime
Ogre Magi
Posts: 1137
Joined: Mon May 07, 2007 3:43 am
Location: Ossining, New York
x 13
Contact:

Re: Windows XP support for 1.9 dropped?

Post by sparkprime »

bstone wrote:... and make the code more efficient by removing unnecessary branching.
In any sane compiler, this is unnecessary. In debug mode you'll get overhead either way (either through if (4 == 4) not being eliminated, or by a call not being inlined). In fact I wouldn't be surprised if the if (4==4) being eliminated even in debug mode since it doesn't interfere with debugging. In optimised mode both cases trivially disappear due to local optimisations. However using extra templates definitely makes the code less readable.

Using template specialisation would avoid the symbol being linked even in debug mode. However it would be better to actually fix the problem (if indeed this is the problem), since it all it takes is someone to instantiate the class in a particular way and it would break XP again.

You are the second (possibly third) person who reads this code and thinks that if (sizeof(T) == 4) { } introduces extra overhead... I don't see anyone providing any evidence of this however and it does not make any sense.

The original code was modified by Sinbad to compile on VC2005. This diff may be the cause of the problem, you should try changing it back and see if that helps. Although since you already tried commenting out the entire line and that did not help, it is unlikely to make a difference.

Code: Select all

--- a/OgreMain/include/OgreAtomicWrappers.h     Thu May 22 21:56:12 2008 +0000
+++ b/OgreMain/include/OgreAtomicWrappers.h     Fri May 23 10:23:51 2008 +0000
@@ -213,12 +213,16 @@
         bool cas (const T &old, const T &nu)
         {
             if (sizeof(T)==2) {
-                return InterlockedCompareExchange16((SHORT*)&mField, static_cast<SHORT>(nu), static_cast<SHORT>(old)) == static_cast<SHORT>(old);
-            } else if (sizeof(T)==4) {
-                return InterlockedCompareExchange((LONG*)&mField, static_cast<LONG>(nu), static_cast<LONG>(old)) == static_cast<LONG>(old);
-            } else if (sizeof(T)==2) {
-                return InterlockedCompareExchange64((LONGLONG*)&mField, static_cast<LONGLONG>(nu), static_cast<LONGLONG>(old)) == static_cast<LONGLONG>(old);
-            } else {
+                return _InterlockedCompareExchange16((SHORT*)&mField, static_cast<SHORT>(nu), static_cast<SHORT>(old)) == static_cast<SHORT>(old);
+            } 
+                       else if (sizeof(T)==4) 
+                       {
+                return _InterlockedCompareExchange((LONG*)&mField, static_cast<LONG>(nu), static_cast<LONG>(old)) == static_cast<LONG>(old);
+                       } 
+                       else if (sizeof(T)==8) {
+                return _InterlockedCompareExchange64((LONGLONG*)&mField, static_cast<LONGLONG>(nu), static_cast<LONGLONG>(old)) == static_cast<LONGLONG>(old);
+            } 
+                       else {
                 OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED,"Only 16, 32, and 64 bit scalars supported in win32.","AtomicScalar::cas");
             }
         }
Post Reply