title: Problems compiling assembly file - Error: undefined reference to `function name'
body: <p>I am trying to take a look at a test program my professor gave us, but I am having trouble compiling it.  I am on Ubuntu 14.04.  I am compiling it with </p>
  
  <pre><code>gcc -Wall test.c AssemblyFunction.S -m32 -o test
  </code></pre>
  
  <p>I was having problems running the code on a 64-bit machine and read that adding -Wall and -m32 will allow it to work.  Doing that fixed the first problem I had, but now I am getting the <strong>error: undefined reference to `addnumbersinAssembly'</strong>. </p>
  
  <p>Here is the C file</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  extern int addnumbersinAssembly(int, int);
  int main(void)
  {
  
      int a, b;
      int  res;
  
      a = 5;
      b = 6;
  
  
      // Call the assembly function to add the numbers
      res = addnumbersinAssembly(a,b);
      printf("\nThe sum as computed in assembly is : %d", res);
  
      return(0);
  }
  </code></pre>
  
  <p>And here is the assembly file</p>
  
  <pre><code>.global _addnumbersinAssembly
  _addnumbersinAssembly:
      pushl   %ebp
      movl    %esp,%ebp
  
  
      movl 8(%ebp), %eax
      addl 12(%ebp), %eax    # Add the args
  
  
      movl    %ebp,%esp
      popl    %ebp
      ret
  </code></pre>
  
  <p>Thank you for your time.  I have been trying to figure this out for hours, so I appreciate any help.</p>