Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't my program find its DLLs on Vista 64?

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.)

like image 315
Mason Wheeler Avatar asked Jan 29 '09 17:01

Mason Wheeler


2 Answers

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.

like image 57
Daniel Rikowski Avatar answered Sep 25 '22 08:09

Daniel Rikowski


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.

like image 33
Matt Lewis Avatar answered Sep 24 '22 08:09

Matt Lewis