Make lwan compilable on Ubuntu 12.04

* Modify the library order to as to ensure that pthread-related
`undefined reference`s are all accounted for. Similarly, move
zlib references to the end. This was an issue for both `lwan`
and `freegeoip` binaries, so fix only those.

* `sqlite3_errstr` remains undefined even after rearranging the
order of library linking. This could be an issue with v3.8.3, but
I am not completely sure. Modifying it to `sqlite3_errmsg` works.