I have been starting to write a mock shell program but came into an issue right away. I am getting a undefined reference to `vtable for Cmd' when compiling my project
Shell.h
#ifndef SHELL_H
#define SHELL_H
#include <iostream>
#include <unistd.h>
#include <stdio.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <stdlib.h>
#include <cstring>
using namespace std;
class Shell
{
protected:
char* cmd;
public:
Shell(): cmd(NULL){};
Shell(char* userInput): cmd(userInput){};
virtual bool execute() = 0;
};
#endif
Cmd.h
#ifndef CMD_H
#define CMD_H
#include <unistd.h>
#include <iostream>
#include <stdio.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <stdlib.h>
#include <cstring>
#include "Shell.h"
using namespace std;
class Cmd : public Shell
{
public:
Cmd(): Shell(NULL) {};
Cmd(char* userInput): Shell(userInput) {};
bool execute();
};
#endif
Cmd.cpp
#include "Cmd.h"
bool Cmd::execute()
{
char * list[1000];
bool status = true;
return status;
}
I researched this and i found out it could be from my makefile or my virtual functions my virtual function is declared
Makefile
COMPILE = g++
FLAGS = -Werror -Wall -ansi
all:
mkdir -p ./bin
$(COMPILE) $(FLAGS) ./src/main.cpp -o ./bin/rshell
main:
$(COMPILE) $(FLAGS) ./src/main.cpp
Cmd:
$(COMPILE) $(FLAGS) ./src/Cmd.cpp
Exit:
$(COMPILE) $(FLAGS) ./src/Exit.cpp
Connector:
$(COMPILE) $(FLAGS) ./src/Connector.cpp
And:
$(COMPILE) $(FLAGS) ./src/And.cpp
Or:
$(COMPILE) $(FLAGS) ./src/Or.cpp
Semi:
$(COMPILE) $(FLAGS) ./src/Semi.cpp
clean:
rm -rf ./bin