0

I'm having some issues trying to Compile a DLL, but I just can't see where this linking error is coming from.

My LNK2019 is:

Exports.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: int 
__thiscall CArray<struct HWND__ *,struct HWND__ *>::Add(struct HWND__ *)" (__imp_?Add@?
$CArray@PAUHWND__@@PAU1@@@QAEHPAUHWND__@@@Z) referenced in function "int __stdcall _Disable(struct 
HWND__ *,long)" (?_Disable@@YGHPAUHWND__@@J@Z)

Disable(...) is...

static BOOL CALLBACK _Disable(HWND hwnd, LPARAM lParam)
{
  CArray<HWND, HWND>* pArr = (CHWndArray*)lParam;
  if(::IsWindowEnabled(hwnd) && ::IsWindowVisible(hwnd))
  {
    pArr->Add(hwnd);
    ::Enable(hwnd, FALSE);
  }
}

This is the first function in Exports.cpp; right above it is

#include <afxtempl.h>

I have the Windows 7.1 SDK installed (and have tried reinstalling both that and VS2010). The exact same project compiles perfectly fine on other machines, so it can't be the code itself.. I've spent countless errors researching, which led to desperate attempts of just changing random values in the solution file, including different Windows headers, etc. My last resort is getting to be just reinstalling the OS completely (assuming it's actually a problem with the Windows SDK being incorrect or something).

Any suggestions at all would be a huge help.

EDIT: I've added /showIncludes on the cpp giving issues, and I do see afxtempl.h being included. It's being included multiple times due to other headers including it, but it is there (and it is from the same directory every time):

1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\afxtempl.h
dajaffe
  • 855
  • 13
  • 34
  • By the way, `_Disable` violates the rules of reserved identifiers because it starts with `_`. See [here](http://stackoverflow.com/questions/228783/what-are-the-rules-about-using-an-underscore-in-a-c-identifier). – chris Sep 23 '12 at 18:03
  • Strange - I'd throw a /showIncludes into the build to see exactly where the headers are coming from. Maybe look at the what the `/E` option generates. It looks like something is screwing up the `AFX_INLINE` macro or something. Is there a `/DAFX_INLINE=something` in the build log? – Michael Burr Sep 23 '12 at 20:46
  • @MichaelBurr No DAFX_INLINE that I can see. I'm adding a /showIncludes for the .cpp giving me troubles now, I'll update the question after it finishes. – dajaffe Sep 23 '12 at 21:28
  • @David: If you do `F12` or `Ctrl-Alt-F12` when the cursor is on the `Add()` call, where does VS take you? If you set the "preprocess to a file" option (`/P`) and search for `::Add`, what does that declaration (or those declarations) look like? – Michael Burr Sep 24 '12 at 01:53
  • F12 does load up the afxtempl.h, to the AFX_INLINE definition of Add(). Compiling with /P right now.. – dajaffe Sep 24 '12 at 02:46

1 Answers1

0

Just for the sake of answering the question - I ended up re-checking out everything from our SVN and re-compiling everything. I think one of our projects was screwing something up for whatever reason.

dajaffe
  • 855
  • 13
  • 34