title: Getting undefined reference to "_printf" error for assembly code despite using gcc linker
body: <p>I am trying to follow the exercise in the book PC Assembly by Paul Carter. <a href="http://pacman128.github.io/pcasm/" rel="nofollow noreferrer">http://pacman128.github.io/pcasm/</a></p>
  
  <p>I'm trying to run the program from 1.4 page 23 on Ubuntu 18. The files are all available on the github site above. </p>
  
  <p>Since original code is for 32bit I compile using </p>
  
  <p>nasm -f elf32 </p>
  
  <p>for first.asm and asm_io.asm to get the object files. I also compile driver.c </p>
  
  <p>I use the linker from gcc and run </p>
  
  <pre><code>gcc -m32 -o first first.o asm_io.o driver.o 
  </code></pre>
  
  <p>but it keeps giving me a bun of errors like</p>
  
  <p>undefined reference to '_scanf'
  undefined reference to '_printf'</p>
  
  <p>(note _printf appears instead of printf because some conversion is done in the file asm_io.asm to maintain compatibility between windows and linux OS's)</p>
  
  <p>I don't know why these errors are appearing. I also try running using linker directly</p>
  
  <pre><code>ld -m elf_i386 -e main -o first -first.o driver.o asm_io.o -I /lib/i386-linux-gnu/ld-linux.so.2 
  </code></pre>
  
  <p>and many variations since it seems that its not linking with the C libraries. </p>
  
  <p>Any help? Stuck on this for a while and couldn't find a solution on similar questions</p>