0

I don't understand what I am doing wrong. It seems the code as basic as it gets:

NeuralNetSettings.h file:

class NeuralNetSettings
{
private:
    int mNumInputs;
    int mNumOutputs;
    int mNumHidden;
    int mNumNeuronsPerHidden;

public:
    NeuralNetSettings();

    int getNumInputs() const { return mNumInputs; }

    int getNumOutputs() const { return mNumOutputs; }

    int getNumHidden() const { return mNumHidden; }

    int getNumNeuronsPerHidden() const { return mNumNeuronsPerHidden; }
};

NeuralNetSettings.cpp:

#include "NeuralNetSettings.h"

NeuralNetSettings::NeuralNetSettings() :
    mNumInputs(0),
    mNumOutputs(0),
    mNumHidden(0),
    mNumNeuronsPerHidden(0) {
}

main function:

#include "NeuralNetSettings.h"

int main() {
    NeuralNetSettings s;

    return 0;
}

Compiler error:

Error 1 error LNK2019: unresolved external symbol "public: __thiscall NeuralNetSettings::NeuralNetSettings(void)" (??0NeuralNetSettings@@QAE@XZ) referenced in function _main C:...\Source.obj NNTester

whats going on here? Should I just never use .cpp files because they seem to be more trouble than they're worth?

Chebz
  • 1,375
  • 3
  • 14
  • 27
  • 2
    It seems that the object file of NeuralNetSettings.cpp is not included in the build of the program. – Vlad from Moscow Jun 25 '15 at 22:24
  • 1
    Some time reading this may help: ["What is an undefined reference/unresolved external symbol error and how do I fix it?"](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – WhozCraig Jun 25 '15 at 22:27
  • hmm how would I do that in VS2012? I basically have 2 projects in the solution: NeuralNet and NNTester (without any additional configurations) – Chebz Jun 25 '15 at 22:27
  • @Michael Naumov Something like "Add existent element" – Vlad from Moscow Jun 25 '15 at 22:28
  • You're using two projects in the same solution? Are the project dependencies established? (I.e. the NNTester project is dependent on the NeuralNet project?) If not, do so. If so, then unless your NeuralNet project produces a static library (as opposed to a DLL) it still won't work as your class members are not being exported). – WhozCraig Jun 25 '15 at 22:29
  • BTW, the filename extension doesn't matter. If you think changing will help, go ahead. I suggest 'for' (fortran), 'f77', 'lsp' or for some real fun, change them to 'exe', 'com' or 'bat'. – Thomas Matthews Jun 25 '15 at 22:35

0 Answers0