?
Solved

RPC linking problems

Posted on 2006-06-12
8
Medium Priority
?
1,309 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

762 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