title: Combining C and Assembly(32 bit code) on Linux 64 bit
body: <p>I have a 64 bit Ubuntu Operating System and I have been learning 32 bit Assembly. I am trying to compile these two files:</p>
  
  <p>square.s:</p>
  
  <pre><code>#square.s
  
  .section .text
  .globl sqr
  .type sqr, @function
  sqr:
      pushl %ebp
      movl %esp, %ebp
      movl 8(%ebp), %eax
      imull %eax, %eax
      popl %ebp
      ret
  </code></pre>
  
  <p>main.c :</p>
  
  <pre><code>//main.c
  #include &lt;stdio.h&gt;
  extern long sqr(long);
  int main(int argc, char* argv[])
  {
      long squared = sqr(10);
      printf("%lu\n", squared);
      return 0;
  }
  </code></pre>
  
  <p>On my 32bit Virtual Machine I compiled them with this command</p>
  
  <pre><code>  gcc main.c square.s -o test
  </code></pre>
  
  <p>and it worked. The problem I am having is that I would like to compile these files on my 64bit machine. I have tried several ways of compiling these files but none have worked.
  Can anyone point me in the right direction? Is there an option to do this? I have tried <strong>-m32</strong> but that didn't work.</p>
  
  <p>When I do this:</p>
  
  <pre><code>  gcc -m32 -o test main.c square.s
  </code></pre>
  
  <p>I get this:</p>
  
  <pre><code>  In file included from /usr/include/stdio.h:28:0,
               from main.c:1:
  /usr/include/features.h:323:26: fatal error: bits/predefs.h: No such file or directory
  compilation terminated.
  </code></pre>