title: Compiling assembly in Visual Studio
body: <p>How do you compile assembly code using Visual Studio?</p>
  
  <p>I want to compile and run an assembly source file in <a href="http://en.wikipedia.org/wiki/Microsoft_Visual_Studio#Visual_Studio_2010" rel="noreferrer">Visual&nbsp;Studio&nbsp;2010</a>.</p>
  
  <p>I've created a Visual C++ project and inserted some assembly code in a file <code>code.asm</code>:</p>
  
  <pre><code>.586              ;Target processor.  Use instructions for Pentium class machines
  .MODEL FLAT, C    ;Use the flat memory model. Use C calling conventions
  .STACK            ;Define a stack segment of 1KB (Not required for this example)
  .DATA             ;Create a near data segment.  Local variables are declared after
                    ;this directive (Not required for this example)
  .CODE             ;Indicates the start of a code segment.
  
  clear PROC
     xor eax, eax 
     xor ebx, ebx 
     ret 
  clear ENDP 
  END
  </code></pre>
  
  <p>However the problem is when you try and compile this, you get:</p>
  
  <pre><code>LINK : error LNK2001: unresolved external symbol _mainCRTStartup
  </code></pre>
  
  <p>I did go and enable the build customization <code>masm.targets</code> (right click project &gt; Build Customizations..), but to no avail.</p>