“LNK2019: unresolved external symbol” When calling my project from a google test project











up vote
-1
down vote

favorite












I searched a lot about this error, but I couldn't find any solution for my specific problem.
I have a project which is working fine when I build or run it in VS 2017. But when I start including one of the files of the project in my google test project, by building my google test project I get this error:




Error LNK2019 unresolved external symbol
"public: __thiscall Classfilter::~Classfilter(void)"
(??1Classfilter@@QAE@XZ) referenced in function __unwindfunclet$??0ClassMissing0@@QAE@PAVClassData@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@11@Z$6
CRHM_Test C:Running_v18_TeeChartAnimated-4CCCC_Testtest.obj 1




I have a file that contains destructor for Classfilter class, here is the code for the destructor:



Classfilter::~Classfilter() {

if (Vs > 0) {
if (!Error) // will not be assigned if error
for (int jj = 0; jj < Vs; ++jj)
delete Data[jj];
delete Data;
delete DataIndx;
delete DataObsCnt;
}
if (Cs > 0) delete Constants;
}


and here is my Classfilter class in the header file:



class __declspec(dllexport) Classfilter {
public:
Classfilter(ClassData *MyObs, string ToVar, string args, string argtypes);

~Classfilter();

ClassData *MyObs;

string ToVar;
string argtypes;
string args;

long Vs;
long Cs;
bool Error;
long ObsCnt;
long TotalCnt; // when created;
bool FirstTime;

long *DataIndx; // Vs offsets
long *DataObsCnt; // maximum number of observations
float ***Data; // Data[Vs selection][Obs][line]
double *Constants; // constant data

ClassVar *thisVar; // last arg accessed
ClassVar *outVar; // ToVar

void Classfilter::readargs();
void error(string Mess);
void fixup(void);
void doFunc(long Obs, long Line) { Data[0][Obs][Line] = 0.0; }
void doFunctions(long Line);
};


I don't understand what is wrong with this class. Please let me know if you have any idea.










share|improve this question






















  • The file containing the destructor is compiled and linked with the rest of your application ? Consult your build log and IDE documentation if the answer to that question is "How do I tell?". Also, you said, "... when I start including one of the files of the project..." - that file you're including in the test project had better be the .cpp implementation(s). Finally,... just.... std::vector.
    – WhozCraig
    Nov 21 at 22:43












  • I'm including the header file, by including the cpp file I have too many errors!
    – Hamid
    Nov 22 at 14:06















up vote
-1
down vote

favorite












I searched a lot about this error, but I couldn't find any solution for my specific problem.
I have a project which is working fine when I build or run it in VS 2017. But when I start including one of the files of the project in my google test project, by building my google test project I get this error:




Error LNK2019 unresolved external symbol
"public: __thiscall Classfilter::~Classfilter(void)"
(??1Classfilter@@QAE@XZ) referenced in function __unwindfunclet$??0ClassMissing0@@QAE@PAVClassData@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@11@Z$6
CRHM_Test C:Running_v18_TeeChartAnimated-4CCCC_Testtest.obj 1




I have a file that contains destructor for Classfilter class, here is the code for the destructor:



Classfilter::~Classfilter() {

if (Vs > 0) {
if (!Error) // will not be assigned if error
for (int jj = 0; jj < Vs; ++jj)
delete Data[jj];
delete Data;
delete DataIndx;
delete DataObsCnt;
}
if (Cs > 0) delete Constants;
}


and here is my Classfilter class in the header file:



class __declspec(dllexport) Classfilter {
public:
Classfilter(ClassData *MyObs, string ToVar, string args, string argtypes);

~Classfilter();

ClassData *MyObs;

string ToVar;
string argtypes;
string args;

long Vs;
long Cs;
bool Error;
long ObsCnt;
long TotalCnt; // when created;
bool FirstTime;

long *DataIndx; // Vs offsets
long *DataObsCnt; // maximum number of observations
float ***Data; // Data[Vs selection][Obs][line]
double *Constants; // constant data

ClassVar *thisVar; // last arg accessed
ClassVar *outVar; // ToVar

void Classfilter::readargs();
void error(string Mess);
void fixup(void);
void doFunc(long Obs, long Line) { Data[0][Obs][Line] = 0.0; }
void doFunctions(long Line);
};


I don't understand what is wrong with this class. Please let me know if you have any idea.










share|improve this question






















  • The file containing the destructor is compiled and linked with the rest of your application ? Consult your build log and IDE documentation if the answer to that question is "How do I tell?". Also, you said, "... when I start including one of the files of the project..." - that file you're including in the test project had better be the .cpp implementation(s). Finally,... just.... std::vector.
    – WhozCraig
    Nov 21 at 22:43












  • I'm including the header file, by including the cpp file I have too many errors!
    – Hamid
    Nov 22 at 14:06













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I searched a lot about this error, but I couldn't find any solution for my specific problem.
I have a project which is working fine when I build or run it in VS 2017. But when I start including one of the files of the project in my google test project, by building my google test project I get this error:




Error LNK2019 unresolved external symbol
"public: __thiscall Classfilter::~Classfilter(void)"
(??1Classfilter@@QAE@XZ) referenced in function __unwindfunclet$??0ClassMissing0@@QAE@PAVClassData@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@11@Z$6
CRHM_Test C:Running_v18_TeeChartAnimated-4CCCC_Testtest.obj 1




I have a file that contains destructor for Classfilter class, here is the code for the destructor:



Classfilter::~Classfilter() {

if (Vs > 0) {
if (!Error) // will not be assigned if error
for (int jj = 0; jj < Vs; ++jj)
delete Data[jj];
delete Data;
delete DataIndx;
delete DataObsCnt;
}
if (Cs > 0) delete Constants;
}


and here is my Classfilter class in the header file:



class __declspec(dllexport) Classfilter {
public:
Classfilter(ClassData *MyObs, string ToVar, string args, string argtypes);

~Classfilter();

ClassData *MyObs;

string ToVar;
string argtypes;
string args;

long Vs;
long Cs;
bool Error;
long ObsCnt;
long TotalCnt; // when created;
bool FirstTime;

long *DataIndx; // Vs offsets
long *DataObsCnt; // maximum number of observations
float ***Data; // Data[Vs selection][Obs][line]
double *Constants; // constant data

ClassVar *thisVar; // last arg accessed
ClassVar *outVar; // ToVar

void Classfilter::readargs();
void error(string Mess);
void fixup(void);
void doFunc(long Obs, long Line) { Data[0][Obs][Line] = 0.0; }
void doFunctions(long Line);
};


I don't understand what is wrong with this class. Please let me know if you have any idea.










share|improve this question













I searched a lot about this error, but I couldn't find any solution for my specific problem.
I have a project which is working fine when I build or run it in VS 2017. But when I start including one of the files of the project in my google test project, by building my google test project I get this error:




Error LNK2019 unresolved external symbol
"public: __thiscall Classfilter::~Classfilter(void)"
(??1Classfilter@@QAE@XZ) referenced in function __unwindfunclet$??0ClassMissing0@@QAE@PAVClassData@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@11@Z$6
CRHM_Test C:Running_v18_TeeChartAnimated-4CCCC_Testtest.obj 1




I have a file that contains destructor for Classfilter class, here is the code for the destructor:



Classfilter::~Classfilter() {

if (Vs > 0) {
if (!Error) // will not be assigned if error
for (int jj = 0; jj < Vs; ++jj)
delete Data[jj];
delete Data;
delete DataIndx;
delete DataObsCnt;
}
if (Cs > 0) delete Constants;
}


and here is my Classfilter class in the header file:



class __declspec(dllexport) Classfilter {
public:
Classfilter(ClassData *MyObs, string ToVar, string args, string argtypes);

~Classfilter();

ClassData *MyObs;

string ToVar;
string argtypes;
string args;

long Vs;
long Cs;
bool Error;
long ObsCnt;
long TotalCnt; // when created;
bool FirstTime;

long *DataIndx; // Vs offsets
long *DataObsCnt; // maximum number of observations
float ***Data; // Data[Vs selection][Obs][line]
double *Constants; // constant data

ClassVar *thisVar; // last arg accessed
ClassVar *outVar; // ToVar

void Classfilter::readargs();
void error(string Mess);
void fixup(void);
void doFunc(long Obs, long Line) { Data[0][Obs][Line] = 0.0; }
void doFunctions(long Line);
};


I don't understand what is wrong with this class. Please let me know if you have any idea.







c++ googletest






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 21 at 22:38









Hamid

299




299












  • The file containing the destructor is compiled and linked with the rest of your application ? Consult your build log and IDE documentation if the answer to that question is "How do I tell?". Also, you said, "... when I start including one of the files of the project..." - that file you're including in the test project had better be the .cpp implementation(s). Finally,... just.... std::vector.
    – WhozCraig
    Nov 21 at 22:43












  • I'm including the header file, by including the cpp file I have too many errors!
    – Hamid
    Nov 22 at 14:06


















  • The file containing the destructor is compiled and linked with the rest of your application ? Consult your build log and IDE documentation if the answer to that question is "How do I tell?". Also, you said, "... when I start including one of the files of the project..." - that file you're including in the test project had better be the .cpp implementation(s). Finally,... just.... std::vector.
    – WhozCraig
    Nov 21 at 22:43












  • I'm including the header file, by including the cpp file I have too many errors!
    – Hamid
    Nov 22 at 14:06
















The file containing the destructor is compiled and linked with the rest of your application ? Consult your build log and IDE documentation if the answer to that question is "How do I tell?". Also, you said, "... when I start including one of the files of the project..." - that file you're including in the test project had better be the .cpp implementation(s). Finally,... just.... std::vector.
– WhozCraig
Nov 21 at 22:43






The file containing the destructor is compiled and linked with the rest of your application ? Consult your build log and IDE documentation if the answer to that question is "How do I tell?". Also, you said, "... when I start including one of the files of the project..." - that file you're including in the test project had better be the .cpp implementation(s). Finally,... just.... std::vector.
– WhozCraig
Nov 21 at 22:43














I'm including the header file, by including the cpp file I have too many errors!
– Hamid
Nov 22 at 14:06




I'm including the header file, by including the cpp file I have too many errors!
– Hamid
Nov 22 at 14:06












1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










My issue is solved by moving body of the method to the header file.
So my header file looks like this:



class __declspec(dllexport) Classfilter {
public:
Classfilter(ClassData *MyObs, string ToVar, string args, string argtypes);

{

if (Vs > 0) {
if (!Error) // will not be assigned if error
for (int jj = 0; jj < Vs; ++jj)
delete Data[jj];
delete Data;
delete DataIndx;
delete DataObsCnt;
}
if (Cs > 0) delete Constants;
}

ClassData *MyObs;

string ToVar;
string argtypes;
string args;

long Vs;
long Cs;
bool Error;
long ObsCnt;
long TotalCnt; // when created;
bool FirstTime;

long *DataIndx; // Vs offsets
long *DataObsCnt; // maximum number of observations
float ***Data; // Data[Vs selection][Obs][line]
double *Constants; // constant data

ClassVar *thisVar; // last arg accessed
ClassVar *outVar; // ToVar

void Classfilter::readargs();
void error(string Mess);
void fixup(void);
void doFunc(long Obs, long Line) { Data[0][Obs][Line] = 0.0; }
void doFunctions(long Line);
};





share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53421409%2flnk2019-unresolved-external-symbol-when-calling-my-project-from-a-google-test%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote



    accepted










    My issue is solved by moving body of the method to the header file.
    So my header file looks like this:



    class __declspec(dllexport) Classfilter {
    public:
    Classfilter(ClassData *MyObs, string ToVar, string args, string argtypes);

    {

    if (Vs > 0) {
    if (!Error) // will not be assigned if error
    for (int jj = 0; jj < Vs; ++jj)
    delete Data[jj];
    delete Data;
    delete DataIndx;
    delete DataObsCnt;
    }
    if (Cs > 0) delete Constants;
    }

    ClassData *MyObs;

    string ToVar;
    string argtypes;
    string args;

    long Vs;
    long Cs;
    bool Error;
    long ObsCnt;
    long TotalCnt; // when created;
    bool FirstTime;

    long *DataIndx; // Vs offsets
    long *DataObsCnt; // maximum number of observations
    float ***Data; // Data[Vs selection][Obs][line]
    double *Constants; // constant data

    ClassVar *thisVar; // last arg accessed
    ClassVar *outVar; // ToVar

    void Classfilter::readargs();
    void error(string Mess);
    void fixup(void);
    void doFunc(long Obs, long Line) { Data[0][Obs][Line] = 0.0; }
    void doFunctions(long Line);
    };





    share|improve this answer

























      up vote
      0
      down vote



      accepted










      My issue is solved by moving body of the method to the header file.
      So my header file looks like this:



      class __declspec(dllexport) Classfilter {
      public:
      Classfilter(ClassData *MyObs, string ToVar, string args, string argtypes);

      {

      if (Vs > 0) {
      if (!Error) // will not be assigned if error
      for (int jj = 0; jj < Vs; ++jj)
      delete Data[jj];
      delete Data;
      delete DataIndx;
      delete DataObsCnt;
      }
      if (Cs > 0) delete Constants;
      }

      ClassData *MyObs;

      string ToVar;
      string argtypes;
      string args;

      long Vs;
      long Cs;
      bool Error;
      long ObsCnt;
      long TotalCnt; // when created;
      bool FirstTime;

      long *DataIndx; // Vs offsets
      long *DataObsCnt; // maximum number of observations
      float ***Data; // Data[Vs selection][Obs][line]
      double *Constants; // constant data

      ClassVar *thisVar; // last arg accessed
      ClassVar *outVar; // ToVar

      void Classfilter::readargs();
      void error(string Mess);
      void fixup(void);
      void doFunc(long Obs, long Line) { Data[0][Obs][Line] = 0.0; }
      void doFunctions(long Line);
      };





      share|improve this answer























        up vote
        0
        down vote



        accepted







        up vote
        0
        down vote



        accepted






        My issue is solved by moving body of the method to the header file.
        So my header file looks like this:



        class __declspec(dllexport) Classfilter {
        public:
        Classfilter(ClassData *MyObs, string ToVar, string args, string argtypes);

        {

        if (Vs > 0) {
        if (!Error) // will not be assigned if error
        for (int jj = 0; jj < Vs; ++jj)
        delete Data[jj];
        delete Data;
        delete DataIndx;
        delete DataObsCnt;
        }
        if (Cs > 0) delete Constants;
        }

        ClassData *MyObs;

        string ToVar;
        string argtypes;
        string args;

        long Vs;
        long Cs;
        bool Error;
        long ObsCnt;
        long TotalCnt; // when created;
        bool FirstTime;

        long *DataIndx; // Vs offsets
        long *DataObsCnt; // maximum number of observations
        float ***Data; // Data[Vs selection][Obs][line]
        double *Constants; // constant data

        ClassVar *thisVar; // last arg accessed
        ClassVar *outVar; // ToVar

        void Classfilter::readargs();
        void error(string Mess);
        void fixup(void);
        void doFunc(long Obs, long Line) { Data[0][Obs][Line] = 0.0; }
        void doFunctions(long Line);
        };





        share|improve this answer












        My issue is solved by moving body of the method to the header file.
        So my header file looks like this:



        class __declspec(dllexport) Classfilter {
        public:
        Classfilter(ClassData *MyObs, string ToVar, string args, string argtypes);

        {

        if (Vs > 0) {
        if (!Error) // will not be assigned if error
        for (int jj = 0; jj < Vs; ++jj)
        delete Data[jj];
        delete Data;
        delete DataIndx;
        delete DataObsCnt;
        }
        if (Cs > 0) delete Constants;
        }

        ClassData *MyObs;

        string ToVar;
        string argtypes;
        string args;

        long Vs;
        long Cs;
        bool Error;
        long ObsCnt;
        long TotalCnt; // when created;
        bool FirstTime;

        long *DataIndx; // Vs offsets
        long *DataObsCnt; // maximum number of observations
        float ***Data; // Data[Vs selection][Obs][line]
        double *Constants; // constant data

        ClassVar *thisVar; // last arg accessed
        ClassVar *outVar; // ToVar

        void Classfilter::readargs();
        void error(string Mess);
        void fixup(void);
        void doFunc(long Obs, long Line) { Data[0][Obs][Line] = 0.0; }
        void doFunctions(long Line);
        };






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 30 at 15:24









        Hamid

        299




        299






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53421409%2flnk2019-unresolved-external-symbol-when-calling-my-project-from-a-google-test%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Lallio

            Unable to find Lightning Node

            Futebolista