Elastic constants from microscopic strain fluctuations