title: SPIM: The following symbols are undefined - but they are
body: <p>I'm new to <code>SPIM</code> and using it to write a mock compiler as a part of compiler design course.</p>
  
  <p>Consider the following program:</p>
  
  <pre><code>.data
  string_access_violation: .asciiz "Access Violation"
  string_illegal_div_by_0: .asciiz "Division By Zero"
  string_invalid_ptr_dref: .asciiz "Invalid Pointer Dereference"
  global_c:   .word 0
  _2_func_name: .asciiz "mul"
  _5_func_name: .asciiz "inc"
  _8_func_name: .asciiz "foo"
  _9_func_name: .asciiz "bar"
  _10_func_name: .asciiz "main"
  
  .text
  .globl main
  
  func1:
      sw $t0, -4($fp)
      sw $t1, -8($fp)
      sw $t2, -12($fp)
      ...
  
  mul:
      ...
  
  func3:
      ...
  
  main:
      jal _0_init_i
      jal _1_init_c
      addi $sp, $sp, -12
      sw $fp, 0($sp)
      sw $ra, 4($sp)
  </code></pre>
  
  <p>I'm getting the following error when trying to run it:</p>
  
  <pre><code>spim: (parser) syntax error on line 86 of file FOLDER_5_OUTPUT/MIPS.txt
          mul:
              ^
  The following symbols are undefined:
  main
  
  Instruction references undefined symbol at 0x00400014
  [0x00400014]    0x0c000000  jal 0x00000000 [main]           ; 188: jal main
  </code></pre>
  
  <p>But <code>main</code> does exists and declare as global. What am I missing?</p>
  
  <hr>
  
  <p><strong>EDIT:</strong> whole code can be found <a href="https://textuploader.com/15481" rel="nofollow noreferrer">here</a>.</p>