Moooo For Me

You will need to first obtain the blueprint for the barn before being able to craft it. The blueprint is unlocked via the livestock tree of the survival panel. Building the composter from the farming and cooking tree isn't required to obtain compost but is required if you want to do this without the hassle of playing on Nightmare difficulty.

Barn Recipe:
 * 80 Wood
 * 20 Shaped Stone Bricks
 * 10 Wheat Bushel
 * 500 Crystal Shards
 * 32 Compost