views:

1497

answers:

2

I recently got a new laptop. Unfortunately, it came with Vista. It's been one big hassle getting it to work, and the comp has hardware components for which there are no XP drivers, so I can't "upgrade" to an OS that actually works. I've mostly gotten things working, but one particularly odd problem has me stumped.

I installed Delphi and tried to build a project. It compiled, but wouldn't run. "This application failed to start because sdl.dll was not found." Fair enough. So I grabbed SDL.dll and put it in the C:\windows\system32 folder. (Using Vista 64-bit Home Premium. This is a 32-bit dll, though, so I put it in the 32 folder instead of the 64 one.)

Hit Run again. Same problem. But why? That's where it goes, right? And C:\windows\system32 is in the system path. Anyone know why it can't link to the DLL?

(And yes, I know that I can work around the problem by putting the DLL in the same folder as the .exe. I'm currently doing that as a workaround. It's a bad idea in the long term, though, because I have a handful of different projects that all require SDL.)

+24  A: 

That is not a Vista problem, but a 64 bit Windows problem: The name System32 is really confusing, but this is actually the folder where the systems (64 bit) DLLs reside.

So on any 64 bit version of Windows...

... all 64 bit system DLLs are located in C:\Windows\System32.

... all 32 bit system DLLs are located in C:\Windows\SysWOW64.

The name comes from Windows on Windows 64 (WOW64) which is the name of the translation layer allowing 32 bit applications to use the native 64 bit system resources.

DR
Thanks, that worked. "Really confusing" indeed. Who set that up?!?
Mason Wheeler
Even worse, when running in 32-bit emulation mode (running any win32 binary) all references to C:\Windows\System32 in the program will be silently rewired to access C:\Windows\SysWOW64 instead. This can occasionally cause weird problems with win32 .exes
Chris Dodd
Wow.. That's just.. sad.. +1 for the info..
krebstar
Because of the name, SysWOW64, I had up to now thought it was the opposite, with 32 bit DLLs in System32, and 64 bit in SysWOW64. I'm glad I ran across your reply, because now I've got it right. Wish I knew that a few days ago. I know it caused me agony when I was trying to get 64-bit PHP going.
lkessler
+8  A: 

Raymond Chen recently addressed the basic reason behind why 32-bit system directories are weird on 64-bit Windows. The first paragraph of the entry is really the key to understanding the reason behind segregated 32-bit directories:

On 64-bit Windows, 32-bit programs run in an emulation layer...If a 32-bit program tries to look at the system, it will see a 32-bit system.

I think you'd have to have separate directories to keep these things all separate and working. The seemingly counter-intuitive name of SysWOW64 for the directory where the files reside is makes more sense when you consider that WOW64 means Windows On Windows 64-bit, which is what the emulater that's mentioned above is called.

Matt Lewis
Nice article. "It works this way because we say it works this way. Just shut up and write some more code. Here, have a glass of Kool-Aid."
Mason Wheeler
Did we read the same article?
Matt Lewis
I'm reading the article you linked. It says that it's "because it's inside an emulator," doesn't actually explain the reasoning behind the backwards naming behavior that DR mentioned, and declares that it's better to work with the system than to fight it.
Mason Wheeler
Ok, I see your confusion now. Edited the answer to explain WOW64.
Matt Lewis
Aha. That makes more sense. (Why couldn't they have said that?) :P
Mason Wheeler
It still doesn't explain why they named the system directory 'system32' on win64 instead of 'system64', which would make a whole lot more sense
Chris Dodd
They really love that half-baked type of explanation.
Fabricio Araujo