Linker error in VS2003.NET projects.

Blackd0t had a problem such as the one described here:

Linker error

The errors are like this:

xxxxxxx error LNK2019: unresolved external symbol "public: int __thiscall CBotApp::Setup(wchar_t *,char *,char *,char *,char *,char *)" (?Setup@CBotApp@@QAEHPA_WPAD1111@Z) referenced in function "public: virtual int __thiscall CxxxxxxtApp::InitInstance(void)" (?InitInstance@CAionBotApp@@UAEHXZ)  
AionBot error LNK2019: unresolved external symbol "public: wchar_t * __thiscall CTranslator::Get(wchar_t *)" (?Get@CTranslator@@QAEPA_WPA_W@Z) referenced in function "protected: virtual int __thiscall CxxxxxxtDlg::OnInitDialog(void)" (?OnInitDialog@CxxxxxxxDlg@@MAEHXZ)

After talking with him, it seemed the problem was that the MFC project was looking for a symbol:

LaunchGame@CBotApp@@QAEHPA_PAD0@Z

And his lib was producing:

LaunchGame@CBotApp@@QAEHPAGPAD0@Z <——– notice the _ is replaced with G.

I had initially thought that he might have something like this in a header:

void foo(int x);

and this in a cpp:

void foo(double x){ return;}

But it turns out that was not the case.

After a bit of deliberation I told him to try undname.exe in the VC/Bin folder of VS. Lo and behold he discovered that 1 project was treating wchar_t as an unsigned short, and the other was treating it as a builtin type!

The lesson? When your linker complains of missing symbols, and you just *know* they are not missing, make sure to check anything that might change the mangling of the names.

Advertisements

~ by ra1ndog on June 8, 2009.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: