Fixed building with proper library order. Not sure if it's the proper autotools way, though