Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
add comment

3 Answers

up vote 1 down vote accepted

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.

share|improve this answer
    
Thank you for this answer; I was thinking of creating a program files folder, but wondered how the library would find the dll. regsvr32 should do that then. Ew the windows environment is so weird =/ –  Chase Meadors Jun 16 '11 at 3:59
    
Windows is weird, but there are analogs. The registry is like /etc and /dev, \Windows is like /sbin, \users is like /home. –  Bacon Bits Jun 16 '11 at 4:02
add comment

If you drop them into c:\windows\system32 they should be accessible by any program (but mainly the cmd prompt).

You can also create your own folder to them anywhere and add the folder to Windows' "Path" variable in the advanced system settings. This will have the same effect.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.