Linker error
-
If i make a library, consists of two files, for example - foo.h, foo.cpp, where i described a class foo: foo.h file:
class foo { ... public: foo(); void method(); }; foo.cpp file: #include "foo.h" foo::foo() { } foo::method() { }
and then i make a new project, copy this files in the project and in file stdafx.h i write next string #include "foo.h" the linker says that can't link... What am i doing wrong? So... I hope i described my problem clearly:) Sorry for my bad english:sigh: -- modified at 1:05 Tuesday 14th February, 2006 -
If i make a library, consists of two files, for example - foo.h, foo.cpp, where i described a class foo: foo.h file:
class foo { ... public: foo(); void method(); }; foo.cpp file: #include "foo.h" foo::foo() { } foo::method() { }
and then i make a new project, copy this files in the project and in file stdafx.h i write next string #include "foo.h" the linker says that can't link... What am i doing wrong? So... I hope i described my problem clearly:) Sorry for my bad english:sigh: -- modified at 1:05 Tuesday 14th February, 2006Firstly you're missing a
void
:**void** foo::method() { }
I'm not sure about the link error. Steve -
Firstly you're missing a
void
:**void** foo::method() { }
I'm not sure about the link error. SteveIt is just mistake in forum... Exactly - i got : error LNK2001: unresolved external symbol "public: __thiscall CFooClass::~CFooClass(void)" (??1CFooClass@@QAE@XZ)
-
It is just mistake in forum... Exactly - i got : error LNK2001: unresolved external symbol "public: __thiscall CFooClass::~CFooClass(void)" (??1CFooClass@@QAE@XZ)
[Message Deleted]
-
It is just mistake in forum... Exactly - i got : error LNK2001: unresolved external symbol "public: __thiscall CFooClass::~CFooClass(void)" (??1CFooClass@@QAE@XZ)
-
It is just mistake in forum... Exactly - i got : error LNK2001: unresolved external symbol "public: __thiscall CFooClass::~CFooClass(void)" (??1CFooClass@@QAE@XZ)
Looks like like your class has declared a destructor but not defined it. ie:
// .h File. class CFooClass { public: CFooClass(); **~CFooClass();** }; // .CPP file CFooClass::CFooClass() { // Blah. } // Where is "CFooClass::~CFooClass() {}" ?
-
Looks like like your class has declared a destructor but not defined it. ie:
// .h File. class CFooClass { public: CFooClass(); **~CFooClass();** }; // .CPP file CFooClass::CFooClass() { // Blah. } // Where is "CFooClass::~CFooClass() {}" ?
Yes, it looks like i don't have a destructor in my cpp file, but i have... I found a way you can check it - in the wizard you can create a new class, but then delete it from the solution, and include it just in stdafx.h. You'll get the same error as I... So my question is - how to include library, without insertig library in the project
-
Yes, it looks like i don't have a destructor in my cpp file, but i have... I found a way you can check it - in the wizard you can create a new class, but then delete it from the solution, and include it just in stdafx.h. You'll get the same error as I... So my question is - how to include library, without insertig library in the project
Are you just including the .H file in your project without the corresponding .CPP file? If this is the case the impementation must come from somewhere...Perhaps you want to build a static library (.LIB file). When you do this you just include the .H file and add the .LIB file to the linker tab (or use a #pragma comment(lib, "libname.lib")). Steve
-
It is just mistake in forum... Exactly - i got : error LNK2001: unresolved external symbol "public: __thiscall CFooClass::~CFooClass(void)" (??1CFooClass@@QAE@XZ)
-
It is just mistake in forum... Exactly - i got : error LNK2001: unresolved external symbol "public: __thiscall CFooClass::~CFooClass(void)" (??1CFooClass@@QAE@XZ)
Rassul Yunussov wrote:
Exactly - i got :error LNK2001: unresolved external symbol "public: __thiscall CFooClass::~CFooClass(void)"
Either you fail to include the .cpp or .library file
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV