Tag Archives: msvc

C++ error LNK2001: unresolved external symbol

A quick Visual C++ tip to help those who get stuck on this problem like I did. If you find yourself getting errors like this:

foo.obj : error LNK2001: unresolved external symbol "public: __thiscall MyMatrix::~MyMatrix(void)" (??1MyMatrix@@QAE@XZ)
foo.obj : error LNK2001: unresolved external symbol "public: __thiscall MyMatrix::MyMatrix(class MyMatrix const &)" (??0MyMatrix@@QAE@ABV0@@Z)
fooData.obj : error LNK2001: unresolved external symbol "public: __thiscall MyMatrix::MyMatrix(unsigned int,unsigned int)" (??0MyMatrix@@QAE@II@Z)
bar.obj : error LNK2001: unresolved external symbol "public: class MyMatrix & __thiscall MyMatrix::resize(unsigned int,unsigned int)" (?resize@MyMatrix@@QAEAAV1@II@Z)
.Release2MCProject-32bit-noxlw.exe : fatal error LNK1120: 4 unresolved externals

it could mean that certain methods are declared but not defined. In other words there may be methods in the header files that have no implementations in cpp files. Above we can see that a destructor, two constructors and a resize call are what the compiler’s complaining about. This was because those methods had not been implemented but were in the header file.

Though the really odd thing is that this project was compiling in 32 bit mode and when I tried to port it to 64 bit mode suddenly these errors crept up. I don’t know why these errors didn’t occur in 32 bit mode. Must be yet another compiling intricacy that I’m not aware of.

C++ can be a nightmare compared to higher level languages.