Where to put libraries and headers on windows (coming from unix?)

Typically the only libraries that are shared are those for Visual Studio, the .NET Frameworks, DirectX, and the Windows API. Other libraries are generally installed to each application directory. Typically if a library needs to be installed for shared use it will do one of two things:

  1. Install to it's own location under Program Files or Program Files\Common Files.
  2. Install to \Windows\System32 or (very rarely) \Windows. This is a throwback to how Windows worked about 10 years ago, and is considered poor practice (if not by programmers by administrators).

Ultimately, however, it doesn't matter where in the file system you put them as long as users have read access to them. Proper dynamic libraries are registered (most respond to regsvr32 <dllname> and regsvr32 /u <dllname>) so the applications which need them will ask the Windows Registry for the library it wants (based on GUID or class name) and the registry knows where the file is. The registry here is acting as a global catalog for installed libraries.

UPDATE:
For reference, here is how Windows searches for libraries you specify by library name.

If you specify the class you need, there are several ways to do that. For example you can use CoGetClassObject if you know the CLSID, which you can get using something like CLSIDFromProgID.


My personal preferences is to do one of the following:

  1. Create a folder in \Program Files\ and put them there. If you need you can add the folder to the PATH, but if you need to register the .dll using regsvr32 you probably won't need to add it to PATH.
  2. Do the same as #1, except create it in a folder somewhere else

You can also put it in %SYSTEMROOT%, but I prefer to keep non Windows items out of that.