title: undefined reference to `main' - collect2: error: ld returned 1 exit status
body: <p>I am trying to compile in a UNIX environment and keep receiving this error. However, all I have is the main function in the file? Any ideas? This is the ONLY code I have since I was having the error in a different file and decided to test the compilation with JUST the main function if a header file is included. I removed the include statement for the headerfile and it compiles just fine. I have tried gcc filename headfilename, just to see if it would make a difference, however, it does not. The header file is located in the same folder.</p>
  
  <p>Any ideas?</p>
  
  <p>Here's the code:</p>
  
  <pre><code>#include "TriePrediction.h"
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  #include &lt;ctype.h&gt;
  
  
  int main(int argc, char **argv)
  {
    return 0;
  }
  </code></pre>
  
  <p>This is the exact error I am getting: </p>
  
  <pre><code>In function `_start':
  (.text+0x18): undefined reference to `main'
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>Compiling with the following line: gcc TriePrediction.c</p>
  
  <p>I have also tried:</p>
  
  <pre><code>gcc TriePrediction.c TriePrediction.h
  </code></pre>
  
  <p>The main function is located in TriePrediction.c</p>
  
  <p>This is the header file: </p>
  
  <p>NOTE: I removed the places I set up the functions for compilation reasons in the file so I know that is wrong , however, I did so to see if that was messing up the compiling with the undefined reference error.</p>
  
  <pre><code>#ifndef __TRIE_PREDICTION_H
  #define __TRIE_PREDICTION_H
  
  #define MAX_WORDS_PER_LINE 30
  #define MAX_CHARACTERS_PER_WORD 1023
  
  // This directive renames your main() function, which then gives my test cases
  // a choice: they can either call your main() function (using this new function
  // name), or they can call individual functions from your code and bypass your
  // main() function altogether. THIS IS FANCY.
  #define main demoted_main
  
  typedef struct TrieNode
  {
      // number of times this string occurs in the corpus
      int count;
  
      // 26 TrieNode pointers, one for each letter of the alphabet
      struct TrieNode *children[26];
  
      // the co-occurrence subtrie for this string
      struct TrieNode *subtrie;
  } TrieNode;
  
  
  // Functional Prototypes
  
  TrieNode *buildTrie(char *filename);
  
  TrieNode *destroyTrie(TrieNode *root);
  
  TrieNode *getNode(TrieNode *root, char *str);
  
  void getMostFrequentWord(TrieNode *root, char *str);
  
  int containsWord(TrieNode *root, char *str);
  
  int prefixCount(TrieNode *root, char *str);
  
  double difficultyRating(void);
  
  double hoursSpent(void);
  
  #endif
  </code></pre>