LordByron
LordByron

Reputation: 83

Visual-C++ Linker Error

I have a class called MODEL in which public static int theMaxFrames resides. The class is defined in its own header file. theMaxFrames is accessed by a class within the MODEL class and by one function, void set_up(), which is also in the MODEL class. The Render.cpp source file contains a function which calls a function in the Direct3D.cpp source file which in turn calls the set_up() function through a MODEL object. This is the only connection between these two source files and theMaxFrames.

When I try to compile my code I get the following error messages:

1>Direct3D.obj : error LNK2001: unresolved external symbol "public: static int MODEL::theMaxFrames" (?theMaxFrames@MODEL@@2HA)

1>Render.obj : error LNK2001: unresolved external symbol "public: static int MODEL::theMaxFrames" (?theMaxFrames@MODEL@@2HA)

1>C:\Users\Byron\Documents\Visual Studio 2008\Projects\xFileViewer\Debug\xFileViewer.exe : fatal error LNK1120: 1 unresolved externals

Upvotes: 1

Views: 666

Answers (1)

CB Bailey
CB Bailey

Reputation: 791361

It sounds very much like you have declared theMaxFrames in the class, but you haven't provided a definition for it.

If this is the case you need to provide a definition for it in a .cpp somewhere.

e.g.

int MODEL::theMaxFrames;

There's a FAQ entry for this question: static data members.

Upvotes: 2

Related Questions