spiffles
asked on
RPC linking problems
Hi,
I'm having problems linking a Test RPC application in VS .NET 2003. I get the following errors:
TestRPC error LNK2001: unresolved external symbol _NdrServerCall2@4
TestRPC error LNK2001: unresolved external symbol _Output
TestRPC error LNK2019: unresolved external symbol __imp__RpcServerListen@12 referenced in function _main
TestRPC error LNK2019: unresolved external symbol __imp__RpcServerRegisterIf @12 referenced in function _main
TestRPC error LNK2019: unresolved external symbol __imp__RpcServerUseProtseq EpA@16 referenced in function _main
It's probably something to do with the name mangling but I cant quite figure it out. Any ideas?
I'm having problems linking a Test RPC application in VS .NET 2003. I get the following errors:
TestRPC error LNK2001: unresolved external symbol _NdrServerCall2@4
TestRPC error LNK2001: unresolved external symbol _Output
TestRPC error LNK2019: unresolved external symbol __imp__RpcServerListen@12 referenced in function _main
TestRPC error LNK2019: unresolved external symbol __imp__RpcServerRegisterIf
TestRPC error LNK2019: unresolved external symbol __imp__RpcServerUseProtseq
It's probably something to do with the name mangling but I cant quite figure it out. Any ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for that. I have a function called output in my idl file:
void Output(
[in] handle_t hBinding,
[in, string] const char* szOutput);
And the output implementation in TestRPC.cpp is:
#include "OutputIf.h"
void Output(handle_t hBinding, const char* szOutput)
{
std::cout << szOutput << std::endl;
}
Any ideas why this isn't linking?
void Output(
[in] handle_t hBinding,
[in, string] const char* szOutput);
And the output implementation in TestRPC.cpp is:
#include "OutputIf.h"
void Output(handle_t hBinding, const char* szOutput)
{
std::cout << szOutput << std::endl;
}
Any ideas why this isn't linking?
What is the error ?
ASKER
The same:
TestRPC error LNK2001: unresolved external symbol _Output
TestRPC error LNK2001: unresolved external symbol _Output
The lack of name mangling suggests that the calling code expects C linkage rather than name-mangled C++ linkage.
Change it as follows in the .cpp file for C-linkage:
extern "C" void Output(handle_t hBinding, const char* szOutput)
{
std::cout << szOutput << std::endl;
}
In the header file prototype it thus:
#ifdef __cplusplus
extern "C"
#endif
void Output(handle_t hBinding, const char* szOutput);
Change it as follows in the .cpp file for C-linkage:
extern "C" void Output(handle_t hBinding, const char* szOutput)
{
std::cout << szOutput << std::endl;
}
In the header file prototype it thus:
#ifdef __cplusplus
extern "C"
#endif
void Output(handle_t hBinding, const char* szOutput);
ASKER
The .h file is generated from the IDL file and I'd prefer not to edit the generated file:
In the generated spec file:
void Output(
/* [in] */ handle_t hBinding,
/* [string][in] */ const unsigned char *szOutput);
In the generated spec file:
void Output(
/* [in] */ handle_t hBinding,
/* [string][in] */ const unsigned char *szOutput);
ASKER
Nevermind i found the problem...unsigned
for this function also you need some .lib file. Check it out.
I never used this function so i don't know the name of .lib file for this function.
Good luck !