title: Undefined reference to an assembly function
body: <p>An assembly function is to be called from a c++ program</p>
  
  <p>My simple <strong>assembly code</strong> is (1.s)</p>
  
  <pre><code>.align 4
  .code 32           
  .globl testfunc 
  .func 
   testfunc:
            bx lr
           .endfunc
   .end
  </code></pre>
  
  <p><strong>C++ code is</strong> (1.cpp)</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  extern "C"
  {
      void testfunc(void);
  }
  
  int main()
  {
     testfunc();
     printf("completed\n");
     return 0;
  }  
  </code></pre>
  
  <p>I compiled assembly code using <strong>arm-none-linux-gnueabi-as -o 1.o 1.s</strong></p>
  
  <p>When C++ code is compiled with <strong>arm-none-linux-gnueabi-g++ -o 1c.o 1.cpp</strong>  getting an error that </p>
  
  <p><strong>In function main, undefined reference to testfunc()</strong></p>
  
  <p>Why is this happening even i declared testfunc() as extern ?</p>