我正在尝试编译该程序,但我在报告日志中不断收到此错误
Undefined symbols for architecture x86_64:
"Net::feedForward(std::__1::vector<int, std::__1::allocator<int> > const&)", referenced from:
_main in main.o
"Net::backProp(std::__1::vector<int, std::__1::allocator<int> > const&)", referenced from:
_main in main.o
"Net::getResults(std::__1::vector<int, std::__1::allocator<int> >&) const", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我的代码直接来自我尝试遵循的youtube教程,这是main.cpp代码:
#include <iostream>
#include <vector>
#include "Net.h"
int main() {
vector<int> topology;
Net myNet(topology);
//constructor needs to know # of layers it wants & # neurons per layer
vector<int> inputVals;
vector<int> targetVals;
vector<int> resultVals;
myNet.feedForward(inputVals);
//feeds inputs to begin with
myNet.backProp(targetVals);
//pass in some array with goal state
myNet.getResults(resultVals);
}
Net.h代码:
#ifndef Net_hpp
#define Net_hpp
#include <stdio.h>
#include <vector>
using namespace std;
class Neuron{};
typedef vector<Neuron> Layer;
class Net{
public:
Net(const vector<int> topology);
void feedForward(const vector<int> &inputVals);
void backProp(const vector<int> &targetVals);
void getResults(vector<int> &resultVals) const;
private:
vector<Layer> m_layers; //m_layers[layerNum][neuronNum]
};
#endif /* Net_hpp */
和Net.cpp代码:
#include "Net.h"
#include <vector>
Net::Net(const vector<int> topology){
int numLayers = topology.size();
for(int layerNum = 0; layerNum < numLayers; ++layerNum){
}
}
我真的不知道如何解决它,而其他类似问题的线程也没有帮助。如果有人可以帮助我,我将不胜感激。