The wall that your barn door track is going on needs to have enough support to take the weight of the door. If you are doing a renovation or new build, add some extra framing timber along the wall, in line with your door lintel. Fill in the whole length of your track, and the wider/higher the better too so you have plenty of room to postion the track up or down if need be. When the wall is finished you can screw the track on the the wall into the solid timber behind it, yay!
If your barn door is going on an existing wall you can cut a strip of gib (presuming thats your wall lining) out of the wall, then do the same thing and add timber in the wall. This also allows you to see what is behind the wall - last thing you want is to be screwing into pipes or wiring. Then patch up/paint the wall. If you don't want or can't do that, another method is to put a board on the wall, say a 150x25 (6x1) or a 200x25 (8x1), screw this on the wall and then screw your track onto the baord. I would not use this method for larger or heavier doors, and bear in mind this will also push the door futher out from the wall.