"So a library can't have any licencing restrictions as to what the code that uses it will do?"
A library certainly can, under certain conditions. Notably a binding contract between the library developer and the end user. Forming that contract is a bit of a trick.
If you download a typical open source library from a web site somewhere, you typically have not clicked on a license agreement. If the web site provides you a legal copy of the software without requiring you to enter into a specific agreement, you now own that copy, and you are not bound by any use license.
The only reason why anyone actually needs to comply with the GPL is so that he/she can legally redistribute modified versions of the software. That requires a license because to do otherwise would violate the copyright of the original authors. No such license is required to use software in any manner that doesn't break copyright (or possibly patent) law, unless the software developer/distributors require you to enter into a licensing agreement before transferring a copy of the software to you.
Shrink wrap licenses are in legal limbo in many areas precisely because this does not happen at the point of purchase. A retail end user now _owns_ a copy of the software, and the First Sale doctrine means that the ability of the software developers to regulate further use has ceased, unless a shrinkwrap licensing agreement is counted as a valid contract between the end user and the original copyright holder no consideration.
If you _own_ a copy of software, or a book, or a CD, what legal principle requires you to enter into a further contract that takes away rights you already have by virtue of that ownership. That is the whole point of the First Sale doctrine, first established by the Supreme Court in 1908, and enshrined into statute in 1978. The software industry wants to take all that away with the pretense that opening shrinkwrap (or clicking yes on a post sale license agreement) constitutes entering into a valid contract. Where's the consideration?
The case for a typical open source license is worse. Where is the contract? A license is not a contract. A legitimate "license agreement" is a contract. A "license" grants you permission to do things you do not already have the right to do. It cannot take away rights you already have, which is why "use license" is an oxymoron.