title: Undefined reference to main from crt1.o
body: <p>Error Message:</p>
  
  <pre><code>/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/crt1.o: In function `_start':
  (.text+0x20): undefined reference to `main'
  collect2: ld returned 1 exit status
  
  
  struct node
  {
    int key_value;
    node *left;
    node *right;
  };
  
  class btree
  {
      public:
          btree();
          ~btree();
  
          void insert(int key);
          node *search(int key);
          void destroy_tree();
  
      private:
          void destroy_tree(node *leaf);
          void insert(int key, node *leaf);
          node *search(int key, node *leaf);
  
          node *root;
  };
  
  btree::btree()
  {
    root=NULL;
  }
  
  void btree::destroy_tree(node *leaf)
  {
    if(leaf!=NULL)
    {
      destroy_tree(leaf-&gt;left);
      destroy_tree(leaf-&gt;right);
      delete leaf;
    }
  }
  
  void btree::insert(int key, node *leaf)
  {
    if(key&lt; leaf-&gt;key_value)
    {
      if(leaf-&gt;left!=NULL)
       insert(key, leaf-&gt;left);
      else
      {
        leaf-&gt;left=new node;
        leaf-&gt;left-&gt;key_value=key;
        leaf-&gt;left-&gt;left=NULL;    //Sets the left child of the child node to null
        leaf-&gt;left-&gt;right=NULL;   //Sets the right child of the child node to null
      }
    }
    else if(key&gt;=leaf-&gt;key_value)
    {
      if(leaf-&gt;right!=NULL)
        insert(key, leaf-&gt;right);
      else
         {
        leaf-&gt;right=new node;
        leaf-&gt;right-&gt;key_value=key;
        leaf-&gt;right-&gt;left=NULL;  //Sets the left child of the child node to null
        leaf-&gt;right-&gt;right=NULL; //Sets the right child of the child node to null
      }
    }
  }
  
  node *btree::search(int key, node *leaf)
  {
    if(leaf!=NULL)
    {
      if(key==leaf-&gt;key_value)
        return leaf;
      if(key&lt;leaf-&gt;key_value)
        return search(key, leaf-&gt;left);
      else
        return search(key, leaf-&gt;right);
    }
    else return NULL;
  }
  
  void btree::insert(int key)
  {
    if(root!=NULL)
      insert(key, root);
    else
    {
      root=new node;
      root-&gt;key_value=key;
      root-&gt;left=NULL;
      root-&gt;right=NULL;
    }
  }
  
  node *btree::search(int key)
  {
    return search(key, root);
  }
  
  void btree::destroy_tree()
  {
    destroy_tree(root);
  }
  </code></pre>
  
  <p>Can anyone tell me where this error message is coming from so I can attempt to fix it? I'm trying to understand nodes better by running programs using nodes, and this error message is thrown.</p>