Disclaimer: In this post we talk about the legal consequences of software licenses. Do not rely on this information for anything important, we might be wrong. Also, this shows the perspective of a programmer who wants to use a library for his non-open-source project. If you are a developer of a library of are doing an open-source project, your view on these licenses will be a different one.
Whenever you write a piece of software, you will probably rely on some third-party library. In many cases you will have the choice between many different libraries, which basically all do the same thing. Making the right decision here can save you a lot of headaches. But which one is the right for you? The obvious criteria is that the library has to be a good piece of software and should be well documented.
However, people tend to forget about the license. Assuming you do not want to pay for it, you will probably choose an open source library. Most people seem to believe that "Open Source" means basically the same thing as "Public Domain", but that's not the case. Neither does open source mean that you can do anything you want with the software, nor do all open source libraries allow the same freedoms in usage.
Why is it important?
The library's license specifies exactly what you are allowed to do with it and what not. All open source licenses require the source code to be publicly available, but besides from that, there are big differences, so this is an important point.
There are licenses that prohibit usage in your software. If you still use such a library, you are infringing the library's author's copyrights. He then has the right to demand royalties from you. This will be much more than you want to pay.
Here is an overview of the most common types of licenses. Wikipedia has a longer list, and detailed articles about many of them.
This license is very restrictive, but luckily not very common among libraries. It forces you to publish any software that makes use of the GPL'd one under a GPL-compatible license, too. This also means that linking with other software is forbidden if they are not both released under GPL-compatible licenses. You are also required to send back any changes you make to the software to the original authors, so they can include them if they want.
Conclusion: You can only use this if you want to release your software under the same license.
This is a moderately restrictive license. It is designed specifically for libraries and allows using the LGPL'd code with code under other licenses, even proprietary code. However, this is only allowed if your own code is not a derivative work. As long as you simply use the library and do not touch the library's code, your software is most likely not a derivative work. The LGPL defines this case as "work that uses the library". If you have such a case, you must provide the user with the possibility to link your program against another version of the library. This is usually done by linking dynamically, but could also be done by publishing the linkable object files of your program. Of course, publishing your source code would also satisfy this condition.
Conclusion: You can use this library in closed-source projects. Impractical for platforms where the user cannot re-link your software (consoles, mobile phones, ...).
MIT, BSD, zLib, Apache
Permissive. This kind of licenses allows pretty much everything, with very few exceptions. They are typically very short, so you can simply read them by yourself. Below is the license text of the MIT license. They allow usage in proprietary code without many restrictions. Usually they contain a phrase that excludes warranty for faults in the code, and one requiring you to not remove or change the license and copyright note when you republish or modify the code. Sometimes you are required to credit the author of the software, sometimes you are forbidden to do so, because no advertising with the name of the author or the library is allowed.
Conclusion: Your best option. Almost no relevant restrictions.
The MIT license text:
Copyright (C) < year > < copyright holders >
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.