title: Calling printf in 64-bit MASM doesn't work (puts works fine)
body: <p>Consider the following assembly (MASM) code (<code>helloworld.asm</code>):</p>
  
  <pre><code>extern puts: PROC
  
  .data
  msg db 'hello world', 0Ah, 00
  
  .code
  main proc
      sub rsp, 40
      lea rcx, msg
      call puts
      add rsp, 40
      ret
  main endp
  
  End
  </code></pre>
  
  <p>It compiles fine under Windows 7 (after installing the necessary development tools and setting up the environment) and behaves as expected:</p>
  
  <pre><code>$ ml64 helloworld.asm /link ucrt.lib vcruntime.lib msvcrt.lib /subsystem:console
  [..]
  
  $ helloworld.exe
  hello world
  </code></pre>
  
  <p>However, if I replace <code>puts</code> with <code>printf</code> in <code>helloworld.asm</code> on line 1 and line 10, the linker fails to resolve the reference to <code>printf</code>:</p>
  
  <pre><code>$ ml64 helloworld.asm /link ucrt.lib vcruntime.lib msvcrt.lib /subsystem:console
  [..]
  helloworld.obj : error LNK2019: unresolved external symbol "printf" referenced in function "main".
  helloworld.exe : fatal error LNK1120: 1 unresolved externals
  </code></pre>
  
  <p>As a bonus: If i use the static library files <code>libucrt.lib</code>, <code>libvcruntime.lib</code> and <code>libcmt.lib</code>, it works with <code>printf</code>:</p>
  
  <pre><code>$ ml64 helloworld.asm /link libucrt.lib libvcruntime.lib libcmt.lib /subsystem:console
  Microsoft (R) Macro Assembler (x64) Version 14.11.25547.0
  Copyright (C) Microsoft Corporation.  All rights reserved.
  
   Assembling: helloworld.asm
  Microsoft (R) Incremental Linker Version 14.11.25547.0
  Copyright (C) Microsoft Corporation.  All rights reserved.
  
  /OUT:helloworld.exe
  helloworld.obj
  libucrt.lib
  libvcruntime.lib
  libcmt.lib
  /subsystem:console
  
  $ helloworld.exe
  hello world
  </code></pre>
  
  <p>This does not make any sense to me. I can obviously compile a C-program with <code>cl</code> which uses the dynamic library files (by specifying the <code>/MD</code> flag) and the linker has no problems resolving the <code>printf</code> symbol.</p>
  
  <p>What is happening here and how can it be solved?</p>