I've arrived late to the discussion, so I have nothing constructive to add on what has already been correctly stated.
I write my libraries at a much higher level of abstraction than those that are readily available for download; in other words, libraries that encapsulate a particular problem domain with which I am working. The library in this context serves only to distill the problem domain into a collection of reusable entities. The more specific to a problem domain you get, the less likely you'll find a library available that accommodates your needs.
I've always followed the software componentry philosophy largely ushered into modern development by those with Unix backgrounds: components, libraries, or classes that do one thing well, and nothing more; one set of cohesive responsibilities, and nothing more. Some call this orthogonality, myself included, and it's witnessed a rebirth in the recent year or so with service-oriented architectures; pipes, filters, orthogonality, etc. are all derived from the foundation provided by earlier Unix pioneers.
With that said, I still sometimes create my own fundamental libraries even when I acknowledge others are available. I do this under the following situations:
- When I consider a library to be nonorthogonal. I despise libraries that could equally serve multiple problem domains, because I find myself with code bloat resulting from superfluous responsibilities in the library. In addition, I find it an encumbrance to reuse as it can't be orchestrated as efficiently as otherwise orthogonal components. You'll note how many of newer Linux OSS projects have moved away from the software componentry ideal (if indeed it can be called that) and instead produce swiss-army programs; programs that do twenty things fairly well, and perhaps one really well.
- When I wish to better understand how a given library works. Many years ago I dissected a C-written barcoding library to better understand the protocols, so in combination with written specifications I was able to acclimate myself more expeditiously. Of course I didn't actually use my library, because that would be irresponsible.
Meh, I can't think of any more.