Sunday, February 17, 2013

[c/c++] LNK2019: unresolved external symbol

1.  if you have static variable, check if it is both declared and defined

http://stackoverflow.com/questions/195207/unresolved-external-symbol-on-static-class-members

in header file:


unsigned char test::X;
unsigned char test::Y;

in the cpp file: 
unsigned char test::X;

Then in the caller function, you can do
test::X = 3; 


2. Check if you copy, pasted and renamed to generate a .h file. 
- you can 'toggle' the 'Show All File' button in the Solution Explorer of Visual Studio to show the structure where Header Files and Source Files are shown in separate folders and check if that header file is there in the Header Files folder.
- if not, exclude it from and then include it into the project

No comments:

Post a Comment