Working in a library is second to none, but the advantage Starbucks has over the library is the late closing. University library hours are one thing, but regular ol' public libraries close too early.
That sucks; you can have coffee in the Chicago and Oak Park libraries.
The library in Quebec city won't even let you have a bottle of water open on your table, forget coffee.
The Minneapolis Public Library has a coffee shop inside.
This varies tremendously from location to location. Covered coffee mugs are often allowed.
Not only they open late and closed early, they are not a good alternative for consistent work particularly if you require your phones to be on. However, libraries are generally better and spacious than coffee shops. mcDonalds is another alternative if you find chairs that are not hard.