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

headerslibrariespathunixwindows 7

When a unix/linux program requires "stuff", I usually put (or dpkg puts for me) libraries and headers in /usr/lib and /usr/include, respectively.

I recently downloaded a library that I wish to use on windows, after recently doing so on my linux machine, that provides a download for a prebuilt windows binary. Of course, this comes with a .dll, a .lib, and a .h file that belong to the library.

My question is, is there any paradigm or pattern as to where I can put these files so that I can make use of them from several different programs/source files? The README supplied with the library made no mention of this, so forgive my ignorance coming from unix. Also, I'm using the command line/gcc toolchain, not VC.

Best Answer

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.

Related Question