I get this error when trying to link a win32 exe project. I have linked in the lib that contains the code for this method. But still gets an unresolved symbol error.
error LNK2001: unresolved external symbol "public: bool __thiscall SharedJobQueue::AddJobA(class boost::shared_ptr<class domain::Job>)" (?AddJobA@SharedJobQueue@@QAE_NV?$shared_ptr@VJob@domain@@@boost@@@Z)
Why does it say AddJobA with the 'A' at the end. The method is declared as AddJob.
I have looked in the output from 'dumpbin /symbols' and it only contains symbols for AddJob not AddJobA. Why do the compiler add an 'A' to the end of the function name?
And here we see the problem with macros.
There is nothing wrong with your code per se, the problem is with the windows libraries. There is actually a function called AddJob in the Win32 headers, but not quite... The don't declare an Addjob function, but instead an AddJobA and an AddJobW function, which deal with non-unicode and unicode strings respectively.
The A
at the end of your function name is due to a macro defined in the windows header that was defined to deal with unicode. Essentially they'll have something like:
#ifdef UNICODE
# define AddJob AddJobW
#else
# define AddJob AddJobA
#endif
This allows people to just use AddJob
and the macros will point the function towards the correct unicode/non-unicode function. The problem of course is that the #define
affects everything, which is what's happening to your function.
To fix this, you can either #undef AddJob
or simply change the name of your function to something that isn't a Win32 function.