title: Command-line to compile Win32 "hello world" in Visual Studio 2005
body: <p>The following basic Win32 program compiles just fine in Dev-C++.</p>
  
  <pre><code>#include &lt;windows.h&gt;
  
  int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){
      MessageBox(NULL,"Hello, world!","My app", MB_OK ) ;
  }
  </code></pre>
  
  <p>But now I'm trying to compile it using Visual Studio 2005. I open the Visual Studio command prompt and type:</p>
  
  <pre><code>cl test.cpp
  </code></pre>
  
  <p>But I get the following errors:</p>
  
  <pre><code>test.cpp
  test.obj : error LNK2019: unresolved external symbol __imp__MessageBoxA@16 referenced in function _WinMain@16
  test.exe : fatal error LNK1120: 1 unresolved externals
  </code></pre>
  
  <p>I thought the problem might be the path for the linker, but according to this <a href="http://msdn.microsoft.com/en-us/library/1xhzskbe%28v=vs.80%29.aspx" rel="nofollow">MSDN page</a>, the linker looks for it in the enviromental variable <code>LIB</code> which is already set in the Visual Studio prompt to:</p>
  
  <pre><code>C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\LIB;
  C:\Program Files\Microsoft Visual Studio 8\VC\LIB;
  C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib;
  C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\lib;
  </code></pre>
  
  <p>What else is needed to compile a Win32 program in the command line?</p>
  
  <p>I'm using Visual Studio 2005 SP1 update for Vista.</p>