Link to home
Start Free TrialLog in
Avatar of spiffles
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__RpcServerUseProtseqEpA@16 referenced in function _main

It's probably something to do with the name mangling but I cant quite figure it out. Any ideas?
ASKER CERTIFIED SOLUTION
Avatar of rajeev_devin
rajeev_devin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rajeev_devin
rajeev_devin

>> NdrServerCall2
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 !

Avatar of spiffles

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?
What is the error ?
The same:
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);
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);

Nevermind i found the problem...unsigned