|
-
August 8th, 2008, 05:46 AM
#1
[RESOLVED] Linking Issues (VC6)
This is making me feel like a real noob. I've opened an old workspace that is a libray and its test harness. It used to work fine and older versions of the code don't work either with the same errors. I've tried recreating the project and that causes the same errors too. Nothing seems out of order in project settings and the code generated works in the main app.
I've stripped out most of the files and got it down to the bare minimum to generate the error. Unfortunately I can't post the project as this is used in production code.
The LNK2001 linker error I get usually means I've left off a library or forgot to implement a virtual function. However this is part of the standard template library - and is a header at that.
The code that is listed as having the problem in IOCompletionPort.obj doesn't actually use std::string directly, but does call a class that does: Comms::Exception accepts a std::string and the value of GetLastError or WSAGetLastError.
The function mentioned in the error (GetMessage) is implemented, but is a virtual function so other classes can override it if need be. However it appears that the compiler has made it Ansi version, but I can't find any options in the settings that would control that. I suspect that might be the problem but since there's very little in the way of options for the library I have no way of knowing for sure. Both projects to specify _MBCS in the compiler options.
Code:
--------------------Configuration: TestComms - Win32 Debug--------------------
Linking...
Comms.lib(IOCompletionPort.obj) : error LNK2001: unresolved external symbol "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall Comms::Exception::GetMessageA(void)const " (?GetMessageA@
Exception@Comms@@UBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
Debug/TestComms.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
TestComms.exe - 2 error(s), 0 warning(s)
Any suggestions? I've lost most of the morning to this and don't want to lose most of the afternoon too.
Thanks, G.
-
August 8th, 2008, 12:07 PM
#2
Re: Linking Issues (VC6)
"GetMessage" is a define from Windows.h....
Code:
#ifdef UNICODE
#define GetMessage GetMessageW
#else
#define GetMessage GetMessageA
#endif // !UNICODE
So if you use this name (as a class method for instance) then it can be changed because of the define. This can end up causing issues - for instance, if you're trying to export explicit names from a DLL. In your case, the issue is probably because not all your projects or source files are being compiled with a consistent UNICODE setting. Compile everything with either UNICODE defined or not defined.
gg
-
August 11th, 2008, 04:06 AM
#3
Re: Linking Issues (VC6)
Spot on.
Where were you on Friday afternoon?!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|