我正在尝试编译别人的 C++ 代码。我自己对 C++ 的经验为 0。我在 MAC 上使用 g++ 来编译我收到的一个 .cpp 文件。当我这样做时,g++ main.cpp
我得到一个未定义的符号错误。谷歌搜索时,答案似乎是关于文件之间的错误链接,但我不知道如何链接文件。我怎样才能让文件编译?我在下面粘贴了完整的代码。
Undefined symbols:
"initializeFitness()", referenced from:
runEvolution() in ccZXBTDH.o
"Grid::GetNeighbourhood(int, int, std::vector<Agent**, std::allocator<Agent**> >&)", referenced from:
runEvolution() in ccZXBTDH.o
runEvolution() in ccZXBTDH.o
runEvolution() in ccZXBTDH.o
"Grid::Grid()", referenced from:
runEvolution() in ccZXBTDH.o
"Reaper::GetAgentToKill()", referenced from:
runEvolution() in ccZXBTDH.o
"Cupid::GetRandomBreeder()", referenced from:
runEvolution() in ccZXBTDH.o
"Reaper::Select()", referenced from:
runEvolution() in ccZXBTDH.o
"Grid::~Grid()", referenced from:
runEvolution() in ccZXBTDH.o
runEvolution() in ccZXBTDH.o
"Breeder::Breed(Agent**, Agent**)", referenced from:
runEvolution() in ccZXBTDH.o
"Cupid::Select()", referenced from:
runEvolution() in ccZXBTDH.o
"Cupid::GetEmptyCell()", referenced from:
runEvolution() in ccZXBTDH.o
"Agent::GetType()", referenced from:
runEvolution() in ccZXBTDH.o
runEvolution() in ccZXBTDH.o
runEvolution() in ccZXBTDH.o
runEvolution() in ccZXBTDH.o
"Breeder::ProcessNeighbourhood(std::vector<Agent**, std::allocator<Agent**> > const&)", referenced from:
runEvolution() in ccZXBTDH.o
"FateAgent::GetGenome(double*)", referenced from:
runEvolution() in ccZXBTDH.o
runEvolution() in ccZXBTDH.o
"Cupid::GetParents()", referenced from:
runEvolution() in ccZXBTDH.o
"Agent::IncreaseAge()", referenced from:
runEvolution() in ccZXBTDH.o
"Grid::GetAgent(int, int)", referenced from:
runEvolution() in ccZXBTDH.o
runEvolution() in ccZXBTDH.o
runEvolution() in ccZXBTDH.o
runEvolution() in ccZXBTDH.o
runEvolution() in ccZXBTDH.o
runEvolution() in ccZXBTDH.o
runEvolution() in ccZXBTDH.o
runEvolution() in ccZXBTDH.o
runEvolution() in ccZXBTDH.o
runEvolution() in ccZXBTDH.o
runEvolution() in ccZXBTDH.o
runEvolution() in ccZXBTDH.o
runEvolution() in ccZXBTDH.o
runEvolution() in ccZXBTDH.o
runEvolution() in ccZXBTDH.o
runEvolution() in ccZXBTDH.o
"FateAgent::GetSelectedCount()", referenced from:
runEvolution() in ccZXBTDH.o
runEvolution() in ccZXBTDH.o
"Breeder::GetGenome(double*)", referenced from:
runEvolution() in ccZXBTDH.o
"Agent::GetFitness()", referenced from:
runEvolution() in ccZXBTDH.o
runEvolution() in ccZXBTDH.o
runEvolution() in ccZXBTDH.o
"Agent::~Agent()", referenced from:
runEvolution() in ccZXBTDH.o
"Grid::DoMovement()", referenced from:
runEvolution() in ccZXBTDH.o
ld: symbol(s) not found
collect2: ld returned 1 exit status