title: How to properly link *.asm file?
body: <p>I have started to learn assembly language and currently making a simple asm program to call printf function in C in stdio.h.<br>
  I am unable to link the object file properly after assembling. The problem I am facing is   </p>
  
  <blockquote>
    <p>undefined reference to printf   </p>
  </blockquote>
  
  <p>After browsing other questions with similar problems on SO, I tried   </p>
  
  <pre><code>nasm -f elf -l call.lst call.asm  
  gcc -o call call.o  
  </code></pre>
  
  <p>After doing this, I get the error:</p>
  
  <blockquote>
    <p>i386 architecture of input file call.o is compatible with x86_64 output.</p>
  </blockquote>
  
  <p>How should I properly link the file? Currently, I am doing the following :- </p>
  
  <pre><code>nasm -f elf call.asm
  ld -m elf_i386 -s -o call call.o
  </code></pre>
  
  <p>What changes should I make to the above line ? </p>