title: Warning: Undefined reference to function
body: <p>I keep getting the warning that my function has an undefined reference and that doesn't really say much to me or how to fix it. Here are the errors</p>
  
  <blockquote>
    <p>log_2.c: In function ‘main’: log_2.c:29: warning: implicit
    declaration of function ‘logbase2’ /tmp/ccAXAmVb.o: In function
    'main': log_2.c:(.text+0x5e): undefined reference to `logbase2'
    collect2: ld returned 1 exit status</p>
  </blockquote>
  
  <p>Heres my code:</p>
  
  <pre><code>int logbasetwo (int number)
  {
  int test;
  for (int i = 0; i&lt; number; i++){
      test = 2 ^ i;
      int result = i;
  }
  
  
  return result;
  }
  
  int main(){
  
  printf("Enter a positive integer: ");
  int number = get_int();
  int logresult;
  if (number &gt; 0){
  logresult=logbase2(number);
  
  }
  
  
  else (number &lt; 0){
      printf("Not a positive number. Re-enter: ");
      number = get_int(); 
  
  }
  
  printf("Log base two of number is:%i", logresult);
  
  
  }
  
  
  return 0;
  }
  </code></pre>