RPC compile problem: Linux <-> Sun

RPC compile problem: Linux <-> Sun

Post by Stan » Sat, 08 Jan 2000 04:00:00



Hi,

    our group at school has written an rpc application under Sun
Solaris. It compiles and works under Sun just fine.
Now we are trying to compile the program under Linux and get the
following error message during compilation:

gcc -ansi -g -D_GNU_SOURCE -c library_clnt.c
gcc -ansi -g -D_GNU_SOURCE -c library_xdr.c
gcc -ansi -pedantic -Wall -g -D_GNU_SOURCE -c client.c
gcc -ansi -pedantic -Wall -g -D_GNU_SOURCE -lnsl library_clnt.o
library_xdr.o client.o -o client
gcc -ansi -g -D_GNU_SOURCE -c library_svc.c
gcc -ansi -pedantic -Wall -g -D_GNU_SOURCE -c server.c
server.c:26: conflicting types for `book_search_1'
library.h:61: previous declaration of `book_search_1'
server.c:85: conflicting types for `enter_book_1'
library.h:64: previous declaration of `enter_book_1'
server.c:127: conflicting types for `delete_book_1'
library.h:67: previous declaration of `delete_book_1'
server.c:181: conflicting types for `get_book_1'
library.h:70: previous declaration of `get_book_1'
server.c:244: conflicting types for `unget_book_1'
library.h:73: previous declaration of `unget_book_1'
make: *** [server.o] Error 1

These are the options we are using in the Makefile

#  Compiler Optionen
CC = gcc -ansi -pedantic -Wall -g -D_GNU_SOURCE
# RPC Compiler Optionen
CC_RPC = gcc -ansi -g -D_GNU_SOURCE

Thanks for any help

Stan

 
 
 

RPC compile problem: Linux <-> Sun

Post by Christopher J. Matter » Sat, 08 Jan 2000 04:00:00



> Hi,
>     our group at school has written an rpc application under Sun
> Solaris. It compiles and works under Sun just fine.
> Now we are trying to compile the program under Linux and get the
> following error message during compilation:
> gcc -ansi -g -D_GNU_SOURCE -c library_clnt.c
> gcc -ansi -g -D_GNU_SOURCE -c library_xdr.c
> gcc -ansi -pedantic -Wall -g -D_GNU_SOURCE -c client.c
> gcc -ansi -pedantic -Wall -g -D_GNU_SOURCE -lnsl library_clnt.o
> library_xdr.o client.o -o client
> gcc -ansi -g -D_GNU_SOURCE -c library_svc.c
> gcc -ansi -pedantic -Wall -g -D_GNU_SOURCE -c server.c
> server.c:26: conflicting types for `book_search_1'
> library.h:61: previous declaration of `book_search_1'
> server.c:85: conflicting types for `enter_book_1'
> library.h:64: previous declaration of `enter_book_1'
> server.c:127: conflicting types for `delete_book_1'
> library.h:67: previous declaration of `delete_book_1'
> server.c:181: conflicting types for `get_book_1'
> library.h:70: previous declaration of `get_book_1'
> server.c:244: conflicting types for `unget_book_1'
> library.h:73: previous declaration of `unget_book_1'
> make: *** [server.o] Error 1
> These are the options we are using in the Makefile
> #  Compiler Optionen
> CC = gcc -ansi -pedantic -Wall -g -D_GNU_SOURCE
> # RPC Compiler Optionen
> CC_RPC = gcc -ansi -g -D_GNU_SOURCE

Looks like you declaraed several things both in library.h
and server.c, and they don't match.  I guess the Sun
compiler ignored it, but the GNU compiler wasn't
willing to put up with it.  Fix your code.  Can't say
more without seeing the relevant lines in server.c
and library.h

                Chris Mattern

 
 
 

RPC compile problem: Linux <-> Sun

Post by Stan » Sat, 08 Jan 2000 04:00:00



> Looks like you declaraed several things both in library.h
> and server.c, and they don't match.  I guess the Sun
> compiler ignored it, but the GNU compiler wasn't
> willing to put up with it.  Fix your code.  Can't say
> more without seeing the relevant lines in server.c
> and library.h

>                 Chris Mattern

Hi Chris,

    the code seems to be ok, but please correct me if I'm wrong. You can
take a look at it bellow (just included the relevant stuff - I hope).
    The library.h is generated by rpcgen from the library.x file. I
would be great if you could take a look at it. Thanks a lot.

Stan

/* Modul:   library.x
(IDL-Datei)                                       */

struct i_entry                  /* Struktur zum Uebergeben der ISBN
Nr.*/
{
 Zeichenkette isbn;

Quote:};

struct book_entry               /* Struktur zum Uebergeben aller
*/
{                               /* relevanten Daten eines Buches
*/
 Zeichenkette isbn;
 Zeichenkette author;
 Zeichenkette title;
 Zeichenkette status;
 Zeichenkette name_of_inquirer;
Quote:};

.
.
.
.
program LIBRARY
{
 version LIBRARYVERSION
 {
  q_result book_search(i_entry) = 1;
  int enter_book(b_entry) = 2;
  int delete_book(i_entry) = 3;
  int get_book(b_get) = 4;
  int unget_book(i_entry) = 5;
 } = 1;                                 /* Versionsnummer       */
Quote:} = 0x20000023;                                /* Programmnummer

*/

*****************************************************************************

/* Modul:   server.c
(Server-Programm)                                  */

#include <rpc/rpc.h>
#include "library.h"
#include "ini.h"

q_result *book_search_1 ( i_entry *ient ) {

/* Code */

 return (&ergebnis);

Quote:}

int *enter_book_1 (b_entry *entry)
{
  /* Code */

  return (&result);
 };

.
.
.
.

****************************************************************************************

/* LIBRARY.H */

/*
 * Please do not edit this file.
 * It was generated using rpcgen.
 */

#ifndef _LIBRARY_H_RPCGEN
#define _LIBRARY_H_RPCGEN

#include <rpc/rpc.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef char Zeichenkette[50];

struct i_entry {
 Zeichenkette isbn;

Quote:};

typedef struct i_entry i_entry;

struct book_entry {
 Zeichenkette isbn;
 Zeichenkette author;
 Zeichenkette title;
 Zeichenkette status;
 Zeichenkette name_of_inquirer;

Quote:};

typedef struct book_entry book_entry;

struct q_result {
 int result;
 Zeichenkette isbn;
 Zeichenkette author;
 Zeichenkette title;
 Zeichenkette status;
 Zeichenkette name_of_inquirer;

Quote:};

typedef struct q_result q_result;

struct b_entry {
 Zeichenkette isbn;
 Zeichenkette author;
 Zeichenkette title;

Quote:};

typedef struct b_entry b_entry;

struct b_get {
 Zeichenkette isbn;
 Zeichenkette name_of_inquirer;

Quote:};

typedef struct b_get b_get;

#define LIBRARY 0x20000023
#define LIBRARYVERSION 1

#if defined(__STDC__) || defined(__cplusplus)
#define book_search 1
extern  q_result * book_search_1(i_entry *, CLIENT *);
extern  q_result * book_search_1_svc(i_entry *, struct svc_req *);
#define enter_book 2
extern  int * enter_book_1(b_entry *, CLIENT *);
extern  int * enter_book_1_svc(b_entry *, struct svc_req *);
#define delete_book 3
extern  int * delete_book_1(i_entry *, CLIENT *);
extern  int * delete_book_1_svc(i_entry *, struct svc_req *);
#define get_book 4
extern  int * get_book_1(b_get *, CLIENT *);
extern  int * get_book_1_svc(b_get *, struct svc_req *);
#define unget_book 5
extern  int * unget_book_1(i_entry *, CLIENT *);
extern  int * unget_book_1_svc(i_entry *, struct svc_req *);
extern int library_1_freeresult (SVCXPRT *, xdrproc_t, caddr_t);

#else /* K&R C */
#define book_search 1
extern  q_result * book_search_1();
extern  q_result * book_search_1_svc();
#define enter_book 2
extern  int * enter_book_1();
extern  int * enter_book_1_svc();
#define delete_book 3
extern  int * delete_book_1();
extern  int * delete_book_1_svc();
#define get_book 4
extern  int * get_book_1();
extern  int * get_book_1_svc();
#define unget_book 5
extern  int * unget_book_1();
extern  int * unget_book_1_svc();
extern int library_1_freeresult ();
#endif /* K&R C */

/* the xdr functions */

#if defined(__STDC__) || defined(__cplusplus)
extern  bool_t xdr_Zeichenkette (XDR *, Zeichenkette);
extern  bool_t xdr_i_entry (XDR *, i_entry*);
extern  bool_t xdr_book_entry (XDR *, book_entry*);
extern  bool_t xdr_q_result (XDR *, q_result*);
extern  bool_t xdr_b_entry (XDR *, b_entry*);
extern  bool_t xdr_b_get (XDR *, b_get*);

#else /* K&R C */
extern bool_t xdr_Zeichenkette ();
extern bool_t xdr_i_entry ();
extern bool_t xdr_book_entry ();
extern bool_t xdr_q_result ();
extern bool_t xdr_b_entry ();
extern bool_t xdr_b_get ();

#endif /* K&R C */

#ifdef __cplusplus

Quote:}

#endif

#endif /* !_LIBRARY_H_RPCGEN */

 
 
 

RPC compile problem: Linux <-> Sun

Post by Richard Huxto » Sun, 09 Jan 2000 04:00:00


Look at the definitions in library.h vs server.c

-Richard Huxton

Quote:

> /* Modul:   server.c
> (Server-Programm)                                  */

> q_result *book_search_1 ( i_entry *ient ) {

> int *enter_book_1 (b_entry *entry)

****************************************************************************
************
Quote:

> /* LIBRARY.H */

> #define book_search 1
> extern  q_result * book_search_1(i_entry *, CLIENT *);
> #define enter_book 2
> extern  int * enter_book_1(b_entry *, CLIENT *);