You need to add -lz somewhere for the linking.