Marci Weinberger

Hi All,

I have a project that build and worked fine all the way through Visual Studio 2003. After upgrading to VS2005 and rebuilding the two dependent libraries I am receiving a linker error on the parent DLL stating:

Error 1 error LNK2001: unresolved external symbol _hInstDLL stdafx.obj
Error 2 error LNK2001: unresolved external symbol _hInstGenDLL stdafx.obj

There is a common header included in one of the libraries and the parent DLL. All files are C++. I can't get rid of the "extern "C"" section because of legacy stuff elsewhere. That header file contains amongst others the following code:

#ifdef __cplusplus

extern "C" {


extern HINSTANCE hInstDLL;

extern HINSTANCE hInstGenDLL;

One of the source files in the library contains the following code fragment:

extern "C"




As you can see (and not for the lack of a blinking cursor in this window on my FireFox browser), I am defining the two variables. The library builds cleaning with no errors or warnings. The main DLL builds cleanly to, but now throws a the two linker errors, which is really one linker error.

The old version of VS (2003) correctly located the two symbols in the library. What do I need to do now

Thanks in advance,

Marci Weinberger

Re: Visual C++ General "Unresolved external symbol" after upgrading to VS05

Peter Ritchie

You need to make sure you define hInstDLL and hInstGenDLL in one of your source (C or CPP) files:


If that is done in a C++ file, wrap it with extern "C" also.