title: Compile another file from the current file
body: <p>I am using Visual Studio 2012.<br>
   I have a Win32 Console project containing the source file "1.cpp". I want to compile some other C++ file (let's say "2.cpp") from within the source code of "1.cpp".<br>
  I tried this-:  </p>
  
  <pre><code>int main()
  {
   system("C:\\\"Program Files (x86)\"\\\"Microsoft Visual Studio 11.0\"\\VC\\vcvarsall.bat");
   system("C:\\\"Program Files (x86)\"\\\"Microsoft Visual Studio 11.0\"\\VC\\bin\\cl.exe /EHsc 2.cpp");
  } 
  </code></pre>
  
  <p>I am doing this because I want to compile "2.cpp" using the <code>/D</code> option to define a macro inside "2.cpp" whose value is calculate within "1.cpp".<br>
  Something like this -:  </p>
  
  <pre><code>int main()
  {
   string mystring;
   system("C:\\\"Program Files (x86)\"\\\"Microsoft Visual Studio 11.0\"\\VC\\vcvarsall.bat");
   system(("C:\\\"Program Files (x86)\"\\\"Microsoft Visual Studio 11.0\"\\VC\\bin\\cl.exe /EHsc /DMYMACRO="+mystring+" 2.cpp").c_str());
  }  
  </code></pre>
  
  <p>Despite executing "vcvarsall.bat" before invoking "cl.exe", I am still getting an error saying <em>"The program can't start because mspdb110.dll is missing from your computer. Try reinstalling the program to fix this problem."</em>   </p>
  
  <p>As mentioned <a href="https://stackoverflow.com/a/84496/1925388">here</a>, I might need to set some environment variables.<br>
  Is there any method of doing this without the need to set environment variables ? If no, then how can I set those variables from within the source "1.cpp" ?</p>