How can I type a program with opencv in using c++?

I am the first time to use opencv, using the source to compile it. But I don’t know how to compile program in command. Someone can tell me how to do?

there are samples to try, e.g. this

also: tutorials

Thanks, you are a handsome man.