To build C/C++ code from command line, the cl.exe binary must be in the path environment variable.

Lets try to compile a single code:

int add(int a, int b) {
  return a + b;
}

int main(int argc, char const *argv[]) {
  int temp = add(5, 15);
  return 0;
}
cl.exe simple.c

That would throw the following error:

LINK : fatal error LNK1104: cannot open file ‘LIBCMT.lib’

Opps!

The reason is, just having the cl binary in the path isn’t enough. cl expects some configuration from the environment variables. This can be setup by executing the following command:

"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7/Tools/VsDevCmd.bat"

Now, the compilation should be smooth:

cl.exe simple.c

Note: This only compiles to 32-bit binaries.