I'm trying compile a program in C++, but the compiler is returning this error:
operadoraarquivos.o: In function `split(std::string, int&)':
operadoraarquivos.cpp:(.text+0x0): multiple definition of `split(std::string, int&)'
main.o:main.cpp:(.text+0x0): first defined here
Hash.o: In function `HashTable::HashTable(int)':
Hash.cpp:(.text+0x65): undefined reference to `Lista<Palavra>::Lista()'
Hash.cpp:(.text+0xba): undefined reference to `Lista<Palavra>::~Lista()'
Hash.o: In function `HashTable::~HashTable()':
Hash.cpp:(.text+0x134): undefined reference to `Lista<Palavra>::~Lista()'
Hash.o: In function `HashTable::inserir(std::string, int)':
Hash.cpp:(.text+0x2d0): undefined reference to `Lista<Palavra>::vazia()'
Hash.cpp:(.text+0x31b): undefined reference to `Lista<Palavra>::buscar(Palavra)'
Hash.cpp:(.text+0x34d): undefined reference to `Lista<int>::Lista()'
Hash.cpp:(.text+0x365): undefined reference to `Lista<int>::inserir(int)'
Hash.cpp:(.text+0x3a5): undefined reference to `Lista<Palavra>::inserir(Palavra)'
Hash.cpp:(.text+0x3ce): undefined reference to `Lista<int>::inserir(int)'
Hash.cpp:(.text+0x3e7): undefined reference to `Lista<int>::Lista()'
Hash.cpp:(.text+0x3ff): undefined reference to `Lista<int>::inserir(int)'
Hash.cpp:(.text+0x43f): undefined reference to `Lista<Palavra>::inserir(Palavra)'
Hash.o: In function `HashTable::buscar(std::string)':
Hash.cpp:(.text+0x590): undefined reference to `Lista<Palavra>::buscar(Palavra)'
Hash.o: In function `HashTable::imprimir(std::string)':
Hash.cpp:(.text+0x6d5): undefined reference to `Lista<int>::imprimir()'
collect2: error: ld returned 1 exit status*****
Command: g++ -o busca main.o operadoraarquivos.o Lista.o Hash.o
How can I fix this error? Thankyou
main.cpp
#include "operadoraarquivos.hpp"
int main(int argc, char* argv[]) {
    OperadoraArquivos opArq(argv[1], argv[2], argv[3]);
    opArq.imprimirBusca();
    opArq.~OperadoraArquivos();
}
operadoraarquivos.cpp
#include "operadoraarquivos.hpp"
OperadoraArquivos::OperadoraArquivos(string livro, string sw, string buscas) {
    this->livro.open(livro.c_str(), ios_base::in);
    this->sw.open(sw.c_str(), ios_base::in);
    this->buscas.open(buscas.c_str(), ios_base::in);
    this->resultados.open(ARQ_RESULTADOS, ios_base::out);
    this->ht = new HashTable(8388593); // 8388593 < 2^23
    stopwords = new string[335];
   // while (!sw.eof())
   //      getline(sw, stopwords[i++]);
    int i = 0;
   while (getline(this->sw, stopwords[i++]));
    string linha;
    for ( i = 1; !this->livro.eof(); i++) {
        getline(this->livro, linha);
        int n;
        string *palavras = split(linha, n);
        for (int j = 0; j < n; j++) {
            if (deveGuardar(palavras[j]))
                ht->inserir(palavras[j], i);
        }
    }
}
OperadoraArquivos::~OperadoraArquivos() {
    this->livro.close();
    this->buscas.close();
    this->resultados.close();
    this->sw.close();
}
bool OperadoraArquivos::deveGuardar(string str) {
    int baixo = 0, alto = 334, meio;
    while (baixo <= alto) {
        meio = (baixo + alto) / 2;
        if (str == stopwords[meio])
            return true;
        else {
            if (str > stopwords[meio])
                baixo = meio;
            else
                alto = meio;
        }
    }
    return false;
}
string OperadoraArquivos::paraMaiuscula(string str) {
    string result = "";
    for ( std::string::iterator it=str.begin(); it!=str.end(); ++it)
        result += toupper(*it);
    return result;
}
void OperadoraArquivos::imprimirBusca() {
    string temp;
    while (getline(buscas, temp)) {
        ht->imprimir(temp);
    }
}
operadoraarquivos.hpp
#ifndef OPERADORAARQUIVOS_H
#define OPERADORAARQUIVOS_H
#include <iostream>
#include <fstream>
#include <cctype>
#include "Hash.hpp"
#define ARQ_RESULTADOS "resultados.txt"
string* split(string str, int &n) {
    int contador = 0;
    for ( string::iterator it=str.begin(); it!=str.end(); ++it) {
        if (*it == ' ')
            contador++;
    }
    string *tokens = new string[contador+1]();
    int i = 0;
    for (string::iterator it=str.begin(); it!=str.end(); ++it) {
        if (*it == ' ')
            i++;
        tokens[i] += *it;
    }
    n = i + 1;
    return tokens;
}
class OperadoraArquivos
{
private:
    string* stopwords;
    ifstream livro;
    ifstream sw;
    ifstream buscas;
    ofstream resultados;
    bool deveGuardar (string str);
    string paraMaiuscula (string str);
    HashTable* ht;
public:
    OperadoraArquivos(string livro, string sw, string buscas);
    ~OperadoraArquivos();
    HashTable* getHashTable();
    void imprimirBusca();
};
#endif // OPERADORAARQUIVOS_H
Hash.cpp
#include "Hash.hpp"
#include "Lista.hpp"
HashTable::HashTable(int max) {
    vetorListas = new Lista<Palavra>[max]();
    this->max = max;
}
HashTable::~HashTable() {
    delete[] vetorListas;
}
int HashTable::hash (string str) {
    Posicao indice = 0;
    int expoente = 0;
    for ( std::string::iterator it=str.begin(); it!=str.end(); ++it)
        indice += (*it) * pow(128,expoente++);
    indice %= max;
}
void HashTable::inserir(string texto, int linha) {
    Palavra palavra;
    Posicao indice = hash(texto);
    palavra.chave = indice;
    palavra.texto = texto;
    if (!vetorListas[indice].vazia())
    {
        No<Palavra>* no = vetorListas[indice].buscar(palavra);
        if (!no) {
            palavra.lista = new Lista<int>();
            palavra.lista->inserir(linha);
            vetorListas[palavra.chave].inserir(palavra);
        }
        else {
            no->item.lista->inserir(linha);
        }
    }
    else {
        palavra.lista = new Lista<int>();
        palavra.lista->inserir(linha);
        vetorListas[indice].inserir(palavra);
    }
}
No<Palavra>* HashTable::buscar (string texto) {
    Palavra palavra;
    palavra.texto = texto;
    palavra.chave = hash(texto);
    return vetorListas[palavra.chave].buscar(palavra);
}
No<Palavra>* HashTable::operator[] (string texto) {
    return buscar(texto);
}
void HashTable::imprimir(string texto) {
    No<Palavra>* no = this->buscar(texto);
    cout << texto << " ";
    no->item.lista->imprimir();
}
Hash.hpp
#ifndef LISTA_H
#define LISTA_H
#include <iostream>
using namespace std;
typedef int chave;
typedef int Posicao;
template <class T>
class No {
public:
 T item;
 No<T> *proximo;
};
template <class T>
class Lista {
private:
    No<T> *prim, *ult;
    void flVazia();
public:
    Lista();
    ~Lista();
    bool vazia();
    void inserir(T x);
    void retira(No<T> *p);
    //No<T>* buscar(Posicao pos);
    No<T>* buscar(T item);
    void imprimir();
    //void imprimeChave(Item item);
};
#endif
Lista.cpp
#include "Lista.hpp"
template <class T>
Lista<T>::Lista() {
    flVazia();
}
template <class T>
Lista<T>::~Lista() {
    while (!vazia())
        retira(ult);
}
template <class T>
void Lista<T>::flVazia() {
    prim = new No<T>();
    //prim->item = {0,0};
    ult = prim;
    ult->proximo = NULL;
}
template <class T>
bool Lista<T>::vazia(){
    return prim == ult;
}
template <class T>
void Lista<T>::inserir(T x) {
    ult->prox = new No<T>();
    ult = ult->prox;
    ult->item = x;
    ult->proximo = NULL;
}
template <class T>
void Lista<T>::retira(No<T> *p) {
    if (vazia() || p == NULL || p->prox == NULL) {
        cout << "Erro: Retirada impossivel" << endl;
    }
    else {
        No<T> *q = p->prox;
        p->prox = q->prox;
        if (p->prox == NULL) ult = p;
        delete(q);
    }
}
/*No<T>* Lista<T>::buscar(Posicao pos) {
    int i=0;
    for (No *p = prim; p!=NULL; p=p->prox) {
        if (pos == i)
            return p;
        ++i;
    }
    return NULL;
}*/
template <class T>
No<T>* Lista<T>::buscar(T item) {
    for (No<T> *p = prim; p!=NULL; p=p->prox) {
            if (p->item == item)
                return p;
        }
        return NULL;
}
/*template <class T>
No<T>* Lista<T>::operator[](Posicao pos)
{
    return buscar(pos);
}*/
template <class T>
void Lista<T>::imprimir() {
    for (No<T>* p = prim; p!=NULL; p=p->prox) {
        cout << p->item;
        if (p->prox!=NULL)
            cout << " ";
    }
    cout << endl;
}
Lista.hpp
#ifndef LISTA_H
#define LISTA_H
#include <iostream>
using namespace std;
typedef int chave;
typedef int Posicao;
template <class T>
class No {
public:
 T item;
 No<T> *proximo;
};
template <class T>
class Lista {
private:
    No<T> *prim, *ult;
    void flVazia();
public:
    Lista();
    ~Lista();
    bool vazia();
    void inserir(T x);
    void retira(No<T> *p);
    //No<T>* buscar(Posicao pos);
    No<T>* buscar(T item);
    void imprimir();
    //void imprimeChave(Item item);
};
#endif
 
     
     
    