how to use rpcgen

Posted on 2008-10-16
Last Modified: 2012-08-14

I am trying to follow a tutorial on using rpcgen. I am new to the C language so I'm just trying to follow exactly as the tutorial says. Please see

When I get up to "cc msg_proc.c msg_svc.c -o msg_server -lnsl " i get the following error:

msg_proc.c:11: error: conflicting types for printmessage_1
msg.h:22: error: previous declaration of printmessage_1 was here

Can anybody tell me what I might be doing wrong? I have copied the code exactly from the website.

If its relevant I am using Ubuntu 8.04

Question by:mstrelan
  • 4
  • 2
LVL 45

Expert Comment

ID: 22728783
Message simply means that you have two declaration of function printmessage_1 and both have different types.
If you check line number 11 in file msg_proc.c and line number 22 in msg.h you would see the two types. You need to resolve the error by using either one of those.

I have not looked through the entire page but I could not locate a msg.h on a quick scan. If you wrote that file, then  you might want to change the declaration in the msg.h file to match the definition in the .c file.
LVL 53

Expert Comment

ID: 22728790
In msg_proc.c, the function's signature is this :

        int * printmessage_1(char **msg, struct svc_req *req)

Check the msg.h file (on the indicated line 22) to see if the function's signature is exactly the same there.
LVL 53

Expert Comment

ID: 22728792
>> but I could not locate a msg.h on a quick scan.

msg.h is generated by rpcgen.
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

LVL 53

Expert Comment

ID: 22728807
If the above doesn't solve your problem, then you need to check for a typo you might have made in msg_proc.c (in the function's signature more specifically), and you should post your msg.x file.
LVL 10

Author Comment

ID: 22728840
thanks for your quick responses... msg.h is auto generated so I probably shouldn't be touching it. here is what I've got...
/* msg.h line 22: */

extern  int * printmessage_1(char **, CLIENT *);

/* msg_proc.c line 11: */

int * printmessage_1(char **msg, struct svc_req *req)


Open in new window

LVL 53

Accepted Solution

Infinity08 earned 500 total points
ID: 22728865
Depending on the platform, you might have to change the function name to printmessage_1_svc in the msg_proc.c file, so :

        int * printmessage_1_svc(char **msg, struct svc_req *req)
LVL 45

Expert Comment

ID: 22728919
what is the definition for CLIENT ? Can it be mapped to struct svc_req? If no then renaming the function in .c is the only option as I08 already said. Also if you need the declaration of the function in msg_proc.c file in some other source file, then you will have to include it using another manually generated .h file.

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

910 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

25 Experts available now in Live!

Get 1:1 Help Now