We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 442

Summary: SDL fails to build: mmintrin.h not present on VC6 with VCSP6?
Product: SDL Reporter: Jason <jesus_freak>
Component: *don't know*Assignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P1    
Version: 1.2.11   
Hardware: x86   
OS: Windows (XP)   

Description Jason 2007-06-20 19:34:33 UTC
I've just downloaded and installed SDL, latest stable version. I'm using Visual C++ 6 with its SP6. The build stops because it can't find mmintrin.h

I downloaded mmintrin.h from Koders thinking that would help, but I now get an error that MMX instruction set is not enabled.

I'm running VC6 on Windows XP with SP2.

I'm not sure if this is a "bug" with your system or with my VC6, but there's no explanation of how to install the already built libraries that I downloaded - only how to build the libraries themselves...
Comment 1 Ryan C. Gordon 2007-06-20 21:59:03 UTC
You probably need the "Processor Pack" add-on to VC6, a free download from Microsoft...but it's probably a bug if we can't work without it.

Sam, is there some #define that we can check to decide if the processor pack is installed (maybe _MSC_VER gets incremented or something)?

(Bumping to P1 for consideration in the 1.2.12 release.)

--ryan.

Comment 2 Jason 2007-06-21 01:20:04 UTC
Some further info, and something extra just in case you need a laugh at how MS have done things...

The downloadable processor pack for VC6 can only be installed with SP5, not SP6 - which is what I've got. The SP doesn't show up in the Add/Remove programs list... Looks like I'm going to have to un-install VC6, patch to SP5, install the PP and patch to SP6 since SP5 hangs on my system. SP6 is supposed to have the PP built in, but... you guessed it, it doesn't.

So, having a way to detect it or its absence would be very nice.

Anyway, the copy of mmintrin.h that I downloaded and put in my include directory contains the following code (at lines 33 and 34):

#ifndef __MMX__
# error "MMX instruction set not enabled"

When I compile, I get the error coming from that directive. So, checking for __MMX__ is probably something you want to do. I'm not sure if that's the *only* thing you want to check for, but I bet it's a start.
Comment 3 Jason 2007-06-21 02:13:50 UTC
Further to my previous comment...

I've got SP5 and the PP installed. When I went to install SP6, it said it could continue to install, but it will wipe out the PP and so there'll no longer be any intrinsic processor support in VC6. So, I either have the PP but be unable to compile anything or a working VC with no PP. If you've got any suggestions on how to get around this, I'd greatly appreciate it as I don't think MS is going to be much of a help - they don't support VC6 any more.

MS does have a workaround for the SP5 thing, but only if you've installed SP6 for Visual Basic (for all of the Visual Studio elements, there is a *single* registry entry to indicate the service pack level, even though most of these things have their own *separate* service packs). Their workaround is to hack the registry so that it says the SP level is only 5. I'm sorely tempted to install SP6, hack the reg, install PP, and then re-set the reg to 6. Looking through the files the PP installs, there doesn't seem to be anything that checks the compiler patch level, and the compiler fixes in SP6 don't affect code production except in a few very minor ways...

If this works, I'll include the MS workaround in this bug report in case you get someone else with this problem... 
Comment 4 Jason 2007-06-21 02:21:55 UTC
The workaround worked. I now have SP6 and PP installed and they both work.

The MS hack is to do with the following key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\6.0\ServicePacks

Install SP6, change the value to 5 via regedit, install PP, then re-set the reg key to 6.
Comment 5 Sam Lantinga 2007-06-21 09:32:00 UTC
FYI, Microsoft recommends not installing SP6.  It's the service pack that wasn't.

Looking for __MMX__ is a nice trick.  I'll take a look at that.  Everywhere else I've seen indicates that there isn't any way to check for the service pack.  Is that symbol defined, now that you have the service pack installed?  Or do you have to include the header which isn't there without the service pack in order to get that define?
Comment 6 Sam Lantinga 2007-06-21 09:33:41 UTC
Sorry, replace "service pack" with "processor pack" in my last comment.
Comment 7 Ryan C. Gordon 2007-06-21 11:27:34 UTC
For testing's sake, mmintrin.h isn't available in Service Pack 6 (it's only in SP5 with the Processor Pack), and should be available in anything newer than VC6.

All of the service packs have the same value for _MSC_VER. Service Pack 5 adds _MSC_FULL_VER, but it's the same value as SP6, I think. Processor pack doesn't appear to change either.

__MMX__ isn't defined by any service pack or the Processor Pack.

Did some research here and found this:

   http://www.winehq.org/pipermail/wine-patches/2004-September/012502.html

Apparently the Processor Pack replaces malloc.h, which is safe to #include in an unpatched VC6 install, but adds a #define _mm_free, so you can test for that, and know if it's safe to #include mmintrin.h ...

Scary, but it works.

I've put a patch into Subversion (revision #3095 for the 1.2 branch, #3096 for the 1.3 branch) to do that test, and some other minor fixes (VC6 doesn't have the Win64 compatibility typedefs for DWORD_PTR, etc). We just disable the Visual C version of the MMX blitters if you aren't on VS.NET, or the Processor Pack isn't installed...this should make everyone happy.

--ryan.

Comment 8 Ryan C. Gordon 2007-06-21 11:52:13 UTC
(Correction: I screwed up the first commit, so it's actually now revision #3097 for the 1.2 branch, #3098 for the 1.3 branch.)

--ryan.

Comment 9 Jason 2007-06-21 17:17:33 UTC
MS might say not to install SP6, but SP5 doesn't work on my system - although on my new hardware (weeks old) it does actually open the IDE... still won't compile properly, tho.

FYI, the __MMX__ thing was only in the version I got off Koders. The one in the VC PP doesn't have that define at all, so it isn't a good thing to test for after all! There's also no cmd-line defines or anything else, so that scary way looks to be the only way to tell.

Thanks for your help and for looking into this.