Skip to main content

Undefined symbols for architecture

Undefined symbols for architecture x86_64:
  "Recipe::Recipe()", referenced from:
      RecipeBook::add(Recipe) in assign6-sendOnline-d41d53.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
     
/tmp/ccFZOs7z.o: In function `RecipeBook::add(Recipe)':
/home/cs/dbrinkley/csci133/assign6/assign6.cpp:30: undefined reference to `Recipe::Recipe()'
collect2: error: ld returned 1 exit status
     
#include <iostream>
#include <string>

class Recipe {
  public:
    std::string name;
    std::string bodyText;

    Recipe();
    Recipe(std::string inName, std::string inBodyText){
      name = inName;
      inBodyText = bodyText;
    };

    Recipe *next, *prev;
};


class RecipeBook {
  private:
    Recipe *head, *tail;    

  public:
    RecipeBook(){
      head = NULL;
      tail = NULL;
    }

    void add(Recipe r){
      Recipe *temp = new Recipe;
      *temp = r;
      if(head == NULL){
        head = temp;
        tail = temp;
        temp = NULL;
      } else {
        tail->next = temp;
        temp->prev = tail;
        tail = temp;
      }
    }
};



int main(){
  RecipeBook rb;
  Recipe r1("hamburger", "cook it");

  rb.add(r1);

  return 0;
}