title: How to link kernel32.lib and user32.lib using a combination of `nasm` and `alink`?
body: <p>How to link kernel32.lib and user32.lib using a combination of <code>nasm</code> and <code>alink</code>?</p>
  
  <p>I'm following some tutorials on assembly programming and the guide wants me to execute the following commands: </p>
  
  <pre><code>nasm  -fobj hello.asm                                    
  alink -oPE hello \lib\kernel32.lib \lib\user32.lib
  </code></pre>
  
  <p>The first command executes as expected, however the second command fails.</p>
  
  <p>To link the .lib files, I've copied them from </p>
  
  <pre><code>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib
  </code></pre>
  
  <p>into my current folder.</p>
  
  <p>The error messages I get when executing the second command is:</p>
  
  <pre><code>Loading file hello.obj
  Loading file Kernel32.lib
  2327 symbols
  Loaded first linker member
  Loading file User32.lib
  1385 symbols
  Loaded first linker member
  matched Externs
  matched ComDefs
  Unresolved external MessageBoxA
  Unresolved external ExitProcess
  </code></pre>
  
  <p>Now, I've two questions:</p>
  
  <p><strong>1) Where are kernel32.lib and user32.lib located?</strong></p>
  
  <p><strong>2) How can I link these library files properly?</strong></p>
  
  <p>The operating system is Windows 10 (64-bit).</p>
  
  <p>Update:</p>
  
  <pre><code>; Coded for NASM                                           ;
  ; nasm  -fobj hello.asm                                    ;
  ; alink -oPE hello \lib\kernel32.lib \lib\user32.lib       ;
                                                             ;
  extern MessageBoxA              ; APIs used                ;
  extern ExitProcess              ; in this file             ;
                                                             ;
  [SECTION CODE USE32 CLASS=CODE] ; code section             ;
  ..start:                        ; for the linker           ;
                                                             ;
      push byte 0                 ; only the buttons 'OK'    ; 
      push dword caption          ; caption of the BOX       ;
      push dword text             ; text in the BOX          ;
      push byte 0                 ; handle of the Box        ;
        call MessageBoxA          ; print BOX on screen      ;
                                                             ;
      push byte 0                 ;                          ;
        call ExitProcess          ; EXIT                     ;
                                                             ;
      caption db "Your first WIN32 programm",0               ;
      text db "HELLO",0                                      ;
                                                             ;
  end                             ; for the linker
  </code></pre>