error LNK2001: unresolved external symbol "public: __
-
Ok, so this is starting to get really annoying. Everytime I write some code and I want to go back to it after I turn my pc off I get this error. I tried using the answer to question 2.7 in the debuging questions article and that did not work....I am really confused why this is happening and I have no idea how to fix it. It is really starting to slow me down :(( Can anyone help me with this?? I have gotten these errors with every MFC program I am writing! Here are the files I'm using. main.cpp radio.h radio.cpp Here is the errors. --------------------Configuration: main - Win32 Debug-------------------- Compiling... main.cpp Linking... main.obj : error LNK2001: unresolved external symbol "public: __thiscall Radio::~Radio(void)" (??1Radio@@QAE@XZ) main.obj : error LNK2001: unresolved external symbol "public: void __thiscall Radio::Display(int)" (?Display@Radio@@QAEXH@Z) main.obj : error LNK2001: unresolved external symbol "public: __thiscall Radio::Radio(void)" (??0Radio@@QAE@XZ) Debug/main.exe : fatal error LNK1120: 3 unresolved externals Error executing link.exe. main.exe - 4 error(s), 0 warning(s) Please help?????? Thanks everyone!!!!! :confused:
-
Ok, so this is starting to get really annoying. Everytime I write some code and I want to go back to it after I turn my pc off I get this error. I tried using the answer to question 2.7 in the debuging questions article and that did not work....I am really confused why this is happening and I have no idea how to fix it. It is really starting to slow me down :(( Can anyone help me with this?? I have gotten these errors with every MFC program I am writing! Here are the files I'm using. main.cpp radio.h radio.cpp Here is the errors. --------------------Configuration: main - Win32 Debug-------------------- Compiling... main.cpp Linking... main.obj : error LNK2001: unresolved external symbol "public: __thiscall Radio::~Radio(void)" (??1Radio@@QAE@XZ) main.obj : error LNK2001: unresolved external symbol "public: void __thiscall Radio::Display(int)" (?Display@Radio@@QAEXH@Z) main.obj : error LNK2001: unresolved external symbol "public: __thiscall Radio::Radio(void)" (??0Radio@@QAE@XZ) Debug/main.exe : fatal error LNK1120: 3 unresolved externals Error executing link.exe. main.exe - 4 error(s), 0 warning(s) Please help?????? Thanks everyone!!!!! :confused:
Try including radio.h and radio.cpp before main.cpp - this error usually occurs when the linker cannot resolve the definitions for the Radio class.
Hush,hush... thought I heard you call my name now. Kula Shaker. Amit Dey Latest articles at CP -
Writing Word addins Office addin -
Try including radio.h and radio.cpp before main.cpp - this error usually occurs when the linker cannot resolve the definitions for the Radio class.
Hush,hush... thought I heard you call my name now. Kula Shaker. Amit Dey Latest articles at CP -
Writing Word addins Office addinMaybe I am not getting this right because I am new to this, but what do you mean? I have main.cpp which looks like this: #include #include #include "Radio.h" int main() { Radio x; //x is the object called. It is of class type Radio int Number = 7; x.Display(Number); return 0; } Radio.cpp is the definitions of Radio.h. Main.cpp is the main program....I dont understand what you mean??
-
Maybe I am not getting this right because I am new to this, but what do you mean? I have main.cpp which looks like this: #include #include #include "Radio.h" int main() { Radio x; //x is the object called. It is of class type Radio int Number = 7; x.Display(Number); return 0; } Radio.cpp is the definitions of Radio.h. Main.cpp is the main program....I dont understand what you mean??
#include "Radio.cpp" or add the cpp file to the project and rebuild.
Hush,hush... thought I heard you call my name now. Kula Shaker. Amit Dey Latest articles at CP -
Writing Word addins Office addin -
#include "Radio.cpp" or add the cpp file to the project and rebuild.
Hush,hush... thought I heard you call my name now. Kula Shaker. Amit Dey Latest articles at CP -
Writing Word addins Office addinOk, that works! But I have another quick question. I have not had to do this before when compiling C++ projects and I also do not have to do it when I create the project from scratch (I only got this problem when I continued working on a project after I turned my PC off). In both my C++ book and my MFC book they only include the hearder.h file. How come in the books they do not include the header.cpp file? Is this something I am going to have to do with all MFC and C++ projects in the future? Thank you for your help Kula, this has really been helpful!
-
Ok, that works! But I have another quick question. I have not had to do this before when compiling C++ projects and I also do not have to do it when I create the project from scratch (I only got this problem when I continued working on a project after I turned my PC off). In both my C++ book and my MFC book they only include the hearder.h file. How come in the books they do not include the header.cpp file? Is this something I am going to have to do with all MFC and C++ projects in the future? Thank you for your help Kula, this has really been helpful!
-
#include "radio.h" into radio.cpp and then #include "radio.h" into main.cpp That should work!
-
I'm not sure what compiler you're using, however I use Visual C++ 6.0. When I create a new Win32/Console application and define a new class I simply insert the header file for the class into main.cpp and everything compiles and links just fine. From what I gather of your original post, it sounds like a compiler configuration issue. You might want to consult Microsoft's Knowledge Base just to find out if this is a known issue and if so, how to fix the problem. I hope this helps. :)
-
I'm not sure what compiler you're using, however I use Visual C++ 6.0. When I create a new Win32/Console application and define a new class I simply insert the header file for the class into main.cpp and everything compiles and links just fine. From what I gather of your original post, it sounds like a compiler configuration issue. You might want to consult Microsoft's Knowledge Base just to find out if this is a known issue and if so, how to fix the problem. I hope this helps. :)