“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.
c++ googletest
add a comment |
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.
c++ googletest
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
add a comment |
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.
c++ googletest
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
c++ googletest
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
add a comment |
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
add a comment |
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);
};
add a comment |
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);
};
add a comment |
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);
};
add a comment |
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);
};
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);
};
answered Nov 30 at 15:24
Hamid
299
299
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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