I am trying to compile and run my c++ code (it is an early version of my code to just check that it would compile). But when I am trying to compile it I get the error:
Undefined symbols for architecture x86_64:
"Net::getResults(std::__1::vector<double, std::__1::allocator<double> > const&) const", referenced from:
_main in nnet-53e1c0.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have included my code down here:
// nnet.cpp
//
//
//
#include <vector>
#include <iostream>
using namespace std;
class Neuron {};
//typer reference
typedef vector<Neuron> Layer;
class Net
{
public:
Net(const vector<unsigned> &topology);
void feedForward(const vector<double> &inputVals) {};
void backProp(const vector<double> &argetVals) {};
void getResults( const vector<double> &resultVals) const;
private:
vector<Layer> m_layers; // m_layers[layerNum][neuronNum]
};
Net::Net(const vector<unsigned> &topology)
{
unsigned numLayers = topology.size();
for(unsigned layerNum =0; layerNum <numLayers; ++layerNum) {
m_layers.push_back(Layer());
// We have made a new Layer, now fill it ith neurons, and
// add a bias neuron to the layer
for (unsigned neuronNum = 0; neuronNum <= topology[layerNum]; ++neuronNum) {
m_layers.back().push_back(Neuron());
cout <<"Made a new Neuron"<<endl;
}
}
}
int main()
{
// e.g (3, 2, 1)
vector <unsigned> topology;
topology.push_back(3);
topology.push_back(2);
topology.push_back(1);
Net myNet(topology);
vector <double> inputVals;
myNet.feedForward(inputVals);
vector <double> targetVals;
myNet.backProp(targetVals);
vector <double> resultVals;
myNet.getResults(resultVals);
}
I am not quite sure what this is about. At first I suspected that this would be about that the vector dynamic library is not linked so I came up with this dummy program to test it:
#include <iostream>
#include <vector>
using namespace std;
int main()
{
cout << "HW is done"<<endl;
printf("Hello");
return 0;
}
This program would surprisingly compile and throws no errors but there are no outputs of it. No printing, nothing.
I am working on a mac and would appreciate if anyone would be able to help me with this issue. Thanks!