Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

RPC linking problems

Posted on 2006-06-12
8
Medium Priority
?
1,333 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 12

Accepted Solution

by:
rajeev_devin earned 240 total points
ID: 16883794
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
ID: 16883799
>> 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
ID: 16883906
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 12

Expert Comment

by:rajeev_devin
ID: 16883966
What is the error ?
0
 

Author Comment

by:spiffles
ID: 16884035
The same:
TestRPC error LNK2001: unresolved external symbol _Output
0
 
LVL 17

Expert Comment

by:rstaveley
ID: 16888284
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
ID: 16890958
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
ID: 16891023
Nevermind i found the problem...unsigned
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

604 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