Linking errors when implementing classes
I have a problem with implementing classes into any programs I create in VC++. I have classes I have created in the past that worked in both gcc on Unix, as well as working in VC++ when I used "main()". However, I''m using "WinMain" now to create a DirectX application, and when I try to use the same classes that worked before, the program compiles, but I''m getting linking errors. Can anyone tell me what the problem might be?
Thanks in advance!
Matt Huggins
Sorry, I meant to include this. Note that the class name is "List".
--------------------Configuration: 3D Engine - Win32 Debug--------------------
Linking...
d3dEngine.obj : error LNK2001: unresolved external symbol "public: __thiscall List::List(void)" (??0?$List@H@@QAE@XZ)
d3dEngine.obj : error LNK2001: unresolved external symbol "public: __thiscall List::~List(void)" (??1?$List@H@@QAE@XZ)
d3dEngine.obj : error LNK2001: unresolved external symbol "public: enum Error_code __thiscall List::insert(int,int const &)" (?insert@?$List@H@@QAE?AW4Error_code@@HABH@Z)
d3dEngine.obj : error LNK2001: unresolved external symbol "public: int __thiscall List::size(void)const " (?size@?$List@H@@QBEHXZ)
Debug/3D Engine.exe : fatal error LNK1120: 4 unresolved externals
Error executing link.exe.
3D Engine.exe - 5 error(s), 0 warning(s)
--------------------Configuration: 3D Engine - Win32 Debug--------------------
Linking...
d3dEngine.obj : error LNK2001: unresolved external symbol "public: __thiscall List
d3dEngine.obj : error LNK2001: unresolved external symbol "public: __thiscall List
d3dEngine.obj : error LNK2001: unresolved external symbol "public: enum Error_code __thiscall List
d3dEngine.obj : error LNK2001: unresolved external symbol "public: int __thiscall List
Debug/3D Engine.exe : fatal error LNK1120: 4 unresolved externals
Error executing link.exe.
3D Engine.exe - 5 error(s), 0 warning(s)
Also note that the linking errors only refer to the functions within the class that I attempt to reference within my program. So I only get errors regarding List::List and List::~List by having this line of code within my project:
List intList;
I only get other errors such as the one about List::insert(int,int const &) when I use intList.insert(...).
Remember, the project worked for me before, so there''s nothing that''s wrong with the coding. (I also got the errors when I tried using collegeboard.org''s AP classes as a test to see if it was my code.)
Thanks again for any help anyone can give!
Matt Huggins
List
I only get other errors such as the one about List::insert(int,int const &) when I use intList.insert(...).
Remember, the project worked for me before, so there''s nothing that''s wrong with the coding. (I also got the errors when I tried using collegeboard.org''s AP classes as a test to see if it was my code.)
Thanks again for any help anyone can give!
Matt Huggins
That''s how a linker works. It doesn''t try to find code for functions you never call in order to cut down on executable size.
Looks like haven''t included your implementation file in the project. Make sure list.cpp (or whatever you''ve called it) is part of the project. If it''s compiled into a seperate library, make sure that .lib file is in the linker''s list of additional libraries.
Looks like haven''t included your implementation file in the project. Make sure list.cpp (or whatever you''ve called it) is part of the project. If it''s compiled into a seperate library, make sure that .lib file is in the linker''s list of additional libraries.
I definately included the list.cpp file, but it still refused to work...I''ll give it another go, but I really don''t know that that''s what''s causing the problem.
Make sure that it isn''t linking an old obj file aswell, one where the functions don''t exist. Click on rebuild all and see if that works.
If at first you don't succeed, redefine success.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement