I am trying to compile a project that contains several .h and .cpp files on Ubuntu using VSCode. However, when I try to build it I receive the error: Udifeind reference to only 2 of my classes that have been defined in one of my .cpp files. I should mention that this project works fine in VS on windows. Is there something wrong with my class definitions for ubuntu?
Important note: I don't think the problem is with linking, because even I run it through the terminal, it gives the same errors.
Could anyone help me with it? Thank you.
These are my classes:
template<typename T>
void Signal::bufferGet(T* valueAddr) {
*valueAddr = static_cast<T*>(buffer)[outPosition];
bufferFull = false;
outPosition = (outPosition + 1) % bufferLength;
bufferEmpty = outPosition == inPosition;
return;
};
template<typename T>
void Signal::bufferPut(T value)
{
(static_cast<T *>(buffer))[inPosition] = value;
inPosition = (inPosition + 1) % bufferLength;
bufferEmpty = false;
bufferFull = inPosition == outPosition;
if(inPosition == 0)
{
if (saveSignal)
{
if (!headerWritten) writeHeader();
if (firstValueToBeSaved <= bufferLength)
{
char *ptr = (char *)buffer;
ptr = ptr + (firstValueToBeSaved - 1) * sizeof(T);
std::ofstream fileHandler{ "./" + folderName + "/" +
fileName, std::ios::out | std::ios::binary | std::ios::app };
fileHandler.write(ptr, (bufferLength -
(firstValueToBeSaved - 1)) * sizeof(T));
fileHandler.close();
firstValueToBeSaved = 1;
}
else
{
firstValueToBeSaved = firstValueToBeSaved -
bufferLength;
}
}
}
}
And this is a part of code that call these classes:
if (process == 0) return false;
for (auto i = 0; i < process; i++)
{
t_binary randomBits;
inputSignals[0]->bufferGet(&randomBits);
outputSignals[0]->bufferPut(randomBits);
outputSignals[1]->bufferPut(randomBits);
outputSignals[2]->bufferPut((t_binary)1);
}
std::cout << process <<" oblivious keys are generated"<< std::endl;
return true;
}
And this what i wrote in terminal (I put all the .cpp and .h in the same place as main.cpp):
g++ -std=c++17 quantum_oblivious_key_distribution_emulator_sdf.cpp
Alice_QOKD_20190816.cpp Bob_QOKD_20190816.cpp
ip_tunnel_linux_20190816.cpp binary_source_20190816.cpp
sink_20190816.cpp netxpto_20190816.cpp -o main