Solved

RPC linking problems

Posted on 2006-06-12
8
1,227 Views
Last Modified: 2012-08-13
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?
0
Comment
Question by:spiffles
  • 4
  • 3
8 Comments
 
LVL 12

Accepted Solution

by:
rajeev_devin earned 60 total points
Comment Utility
You need to add Rpcrt4.lib in your linker settings for there functions

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
0
 
LVL 12

Expert Comment

by:rajeev_devin
Comment Utility
>> 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 !

0
 

Author Comment

by:spiffles
Comment Utility
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?
0
 
LVL 12

Expert Comment

by:rajeev_devin
Comment Utility
What is the error ?
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:spiffles
Comment Utility
The same:
TestRPC error LNK2001: unresolved external symbol _Output
0
 
LVL 17

Expert Comment

by:rstaveley
Comment Utility
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);
0
 

Author Comment

by:spiffles
Comment Utility
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);

0
 

Author Comment

by:spiffles
Comment Utility
Nevermind i found the problem...unsigned
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now