When you want to install openssl or anything by HomeBrew in El Capitan, you might get “cannot run C compiled programs” error message.
This blog provided solution for it.
The root cause is the Xcode command tool.
If you still got the message after Xcode command tool installation, you should check the path definition.
You can run
to get the path, in my case that is
But my Xcode 7.0 installed in
/Applications/Xcode-beta.app/Contents/Developer, so I change the path by
xcode-select -s /Applications/Xcode-beta.app/Contents/Developer/
And then Brew work again, get rid of the error.