Can I combine 2x4 lumber to build posts for barn?
To partially reiterate my comment, that's a common strategy even for commercial buildings, but for that length you should be using 2x6. So the answer is "yes". 

However, the specifics are important. Adequate lap, joint scatter, and fastener type and schedule are all critical factors in your success.