title: Linking C function lib to x86 assembly program in modern 64bit Linux
body: <p>I'm going through a book focusing on x86 programming (Professional Assembly Language, WROX 2005). I had some problems last night and I was hoping to sort this out before returning home today so I can get a running-start and continue the text. My machine runs x64 Ubuntu (11.04 if I'm not mistaken) so the text focusing on 32bit x86 is slightly 'outdated' (I have to add --32 when assembling etc).</p>
  
  <p>I am trying to dynamically link C-library functions with my assembly program but I am unsuccesfull (below commands are from memory).</p>
  
  <pre><code>ld -dynamic-linking /lib/ld-linux.so.2 -o complex -lc complex.o -m elf_i386
  </code></pre>
  
  <p>Running the above command in Linux gives me the message that it can't understand -lc. Okay, so I removed it.</p>
  
  <pre><code>ld -dynamic-linking /lib/ld-linux.so.2 -o complex complex.o -m elf_i386
  </code></pre>
  
  <p>I then get the notification that 'printf' is not recognised. The hopes was for the dynamic linker to link to the library but it does not seem to do so. Going to \lib\ I could not locate ld-linux.so.2 (strangely it didn't give me an error on this) but I did locate ld-linux-86-64.so.2. My code is 32bit but I thought what the heck, let's try this:</p>
  
  <pre><code>ld -dynamic-linking /lib/ld-linux-86-64.so.2 -o complex complex.o -m elf_i386
  </code></pre>
  
  <p>Still it gave the same error that 'call printf' was not recognized.</p>
  
  <p>Need help dynamically linking C library functions with my 32bit Assembly program using 64bit Linux and standard GNU tools.</p>