I got a problem that I couldn't find an answer to, even though a similar question has been asked here before.
So, in my project, I have the following source code structure:
src
|-main
||-Main.cpp
||-Simulation.h
||-Simulation.cpp
|-inputInterpreter
||-InputInterpreter.h
||-InputInterpreter.cpp
|-utils
||-Utils.h
||-Utils.cpp
In my Main.cpp
I have the following source code:
#include <iostream>
#include "../inputInterpreter/InputInterpreter.h"
#include "../utils/Utils.h"
int main() {
std::cout << "Welcome. For help, type 'help'" << std::endl;
std::string in;
in = Utils::getInput();
while (not Utils::startsWith("quit", in)) {
InputInterpreter::interpretInput(in);
in = Utils::getInput();
};
}
and I get the following error message when I try to compile it with g++:
/cygdrive/c/Users/Acer/AppData/Local/Temp/ccM3znYC.o:Main.cpp:(.text+0x4d): undefined reference to `Utils::getInput()'
/cygdrive/c/Users/Acer/AppData/Local/Temp/ccM3znYC.o:Main.cpp:(.text+0xb6): undefined reference to `Utils::startsWith(std::string, std::string)'
/cygdrive/c/Users/Acer/AppData/Local/Temp/ccM3znYC.o:Main.cpp:(.text+0x104): undefined reference to `InputInterpreter::interpretInput(std::string)'
/cygdrive/c/Users/Acer/AppData/Local/Temp/ccM3znYC.o:Main.cpp:(.text+0x128): undefined reference to `Utils::getInput()'
collect2: error: ld returned 1 exit status
What could be the error? I already included each .h in every source file (as seen above).
Thank you everyone.