You are here:

C++/LNK2001 - unresolved external symbol

Advertisement


Question
I am working in XP, Visual C++ v6 doing maintenance on existing games. I am new to C++ language and to game programming. I have a linking error and would appreciate some expert help.

Animate.obj : error LNK2001: unresolved external symbol "public: __thiscall XCFramePlay::XCFramePlay(class CDC &,int,int)" (??0XCFramePlay@@QAE@AAVCDC@@HH@Z)

Thank you and any help would be appreciated.

Answer
Tom Hicks , Thank you for your question.

This is an error caused by a program reference that was not satisfied by any object file in the list of files being linked.

For example, suppose I write the code

void ABC();
ABC();

There will be no compilation error, because the syntax is correct. The resulting object file will call a function 'ABC' which it expects to find in another compilation unit or in a library.

But if this is the only code, the linker will report that 'ABC' is unresolved. The program cannot run because the actual definition of 'ABC' cannot be found.

The linker adds "decoration" to the names it looks up. The decoration represents the data type of the name. The linker does this because it is very simple and does not "understand" what a datatype is.

In your case, a constructor for the class XCFramePlay is missing from your project file list and/or library list. You can look up 'XCFramePlay' in Microsoft's MSDN Library at http://search.microsoft.com/us/dev/default.asp. If you don't find it, that probably means that your code is using a custom library that is missing.

David Spector

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


David Spector

Expertise

Highly knowledgeable in the C++ language, Visual C++ (MSVC), Windows API, documentation and other quality-assurance techniques, and debugging. Knowledgeable in MFC, COM, GUI design, and object-oriented design.

Experience

I have been a software engineer since 1965. I have been published. My specializations have been: biomedical programming, compiler implementation, and many kinds of Windows programming. I don't do Databases or other business-oriented stuff.

Publications
Windows?/DOS Developer's Journal, ACM SIGPLAN Notices, and Computer Science Press.

Education/Credentials
ICCP Systems Programming Certification
Master's degree equivalent in Computer Science

©2016 About.com. All rights reserved.