title: undefined symbols in .o file
body: <p>I am using icc12 to make a project that contains three files:</p>
  
  <p>.s file containing a series of subroutines in assembly language</p>
  
  <p>.h file with a list of the functions</p>
  
  <p>.c program containing my main code where I call upon my subroutines</p>
  
  <p>My issue is that when I compile my C program the compiler displays the following errors:</p>
  
  <pre><code> !ERROR file 'filename.o': undefined symbol '_lcd_putstr'
   !ERROR file 'filename.o': undefined symbol '_lcd_init'
   !ERROR file 'filename.o': undefined symbol '_lcd_move'
   !ERROR file 'filename.o': undefined symbol '_lcd_clear'
  </code></pre>
  
  <p>I have been doing some research into what a .o file actually is and I understand that it is an object file containing machine code that the CPU understands.  They contain information that allow a linker to see what symbols it requires in order to work.  I still don't understand how I can fix these errors though from this.  I have checked for any grammatical mistakes but I cant seem to locate any.  Is anybody able to offer some help on how I can make these symbols 'defined' in my .o file?</p>
  
  <p>My build commands are</p>
  
  <pre><code> #include &lt;stdio.h&gt;
   #include &lt;mc9s12dp512.h&gt;
   #include "lcd.h"
  
   int main (void)
   {
        unsigned char keycode;
        int keysave = 0;
  
        DDRB = 0x00;    /* make Port B an input port */
  
        lcd_init();  // initialise the lcd module
        lcd_clear(); // clear the lcd module
  
        // print the welcome message on the LCD module
        lcd_putstr(" message A ");
  
        // move the cursor position down a line
        lcd_move(1,1);
        lcd_putstr(" message B ");
  
        // move the cursor position down a line
        lcd_move(1,2);
        lcd_putstr(" message C ");
  
        // move the cursor position down a line
        lcd_move(1,3);
        lcd_putstr(" message D ");
  </code></pre>
  
  <p>Excerpt from assembly file for <code>_lcd_putstr</code></p>
  
  <pre><code> _lcd_putstr::
               pshx
               tfr     d,x             ; Transfer address of string to X
               ldaa    #WRDATA         ; Set up command for write data
               jsr     WriteBytes      ; Call subroutine to write byte to LCD
               pulx
               rts
  </code></pre>