0

I am trying to write an open hash table and use cuckoo hashing, so I need two hash functions. I am trying to use a SHA1 hash function that I found online.

This is the function I am trying to use SHA1 in:

#include sha1.h
...
size_t hash2(K key){
    SHA1 sha1;
    std::string hash = sha1(&key, sizeof(key));
    return stoi(hash)%current_capacity;
}

However whenever I compile I get this error:

g++    -c -o sequential.o sequential.cpp
g++ -Wall -g -o P3 P3.o sequential.o concurrent.o
P3.o: In function `Openhash_seq<int, int>::hash2(int)':
/home/jra221/cse375/project3/sequential.cpp:46: undefined reference to `SHA1::SHA1()'
/home/jra221/cse375/project3/sequential.cpp:47: undefined reference to `_ZN4SHA1clB5cxx11EPKvm'
collect2: error: ld returned 1 exit status
make: *** [P3] Error 1

It may be that I am compiling wrong, or missing a file, but both sha1.h and sha1.cpp are in the same directory as the file that has this function. I think its something simple.

angelly17
  • 1
  • 1
  • You need to actually compile `sha1.cpp` and link the resulting object file into the final executable. It is not enough to have the .cpp file exist in the folder. – Remy Lebeau Nov 13 '21 at 21:33

0 Answers0