I have tried everything I know of on this bastard.
Header:
#ifdef DLL_EXPORTS
#define DLL_API _declspec(dllexport)
#else
#define DLL_API _declspec(dllimport)
#endif
class DLL_API Class : public AnotherClass
{
static int s_static;
public:
static const int * Static() { return &s_static; }
void NonStatic();
};
Cpp:
int Class::s_static = 10;
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
{
GlobalFunctionInAnotherDll(Class::Static());
return TRUE;
}
void Class::NonStatic()
{
}
This DLL builds fine.
Another project attempts to use Class::Static(). It builds fine in debug mode, it has an unresolved external on the Class::s_static in release mode. In both builds, Class::NonStatic AND Class::Static() resolves just fine.
I've tried:
- Scouring the properties for each config a dozen times for differences, nothing.
- Project dependencies are correct
- putting _declspec(dllexport) on the definition of Class::s_static;
- Searching the exp file for the decorated name (it is there)
- Linking the client project directly to the export library
- A few other things, none of which could explain it failing to resolve s_static while resolving Static() and NonStatic().
- Most importantly, I did dumpbin /exports on the DLL, and the symbol is there! I copied it, pasted it in a text file, then copied the compiler output and did a search just to make sure I wasn't miscounting an @ symbol or anything like that. It is identical. It is also in the .lib file.
I've built about 15 DLLs in this project from scratch, and come across my fair share of these linker errors. Of all of the problems that I've had, none of them were this stubborn, and none of the fixes for any of them in the past I can remember will fix this one. Mainly, what could possibly cause this one symbol to fail to resolve, while the other symbols in the class resolve just fine? And that it appears in the DLL exports and lib exports?