[C][RPC][Solaris]Not compiling client/server


 
Thread Tools Search this Thread
Top Forums Programming [C][RPC][Solaris]Not compiling client/server
# 1  
Old 01-06-2012
[C][RPC][Solaris]Not compiling client/server

Hello,
I have task to make a program that multiplies polynomials as client(input/output indexes)-server(multiplying) using RPC. However when I try to compile it with gcc it gives the next info:

for client:
Udefined first
symbol referenced
Clnt_create client.o

for server:
Udefined first
symbol referenced
mlt_proc_1 mlt_svc.o

What could be done with it?(Some libs problems(?), mb missing some include files?)

here the listings:
mlt.x
Code:
struct mlt_in { /* входные данные (аргумент) */
int f[20];
int g[20];
};

struct mlt_out { /* возвращаемые данные (результат) */
int d[40];
};

program MLT_PROG {
version MLT_VERS {
mlt_out MLTPROC(mlt_in) = 1; /* номер процедуры = 1 */
} = 1;
} = 0x31230000;

client.c
Code:
#include "mlt.h" /*rpcgen */
#include <stdio.h>
#include <rpc/rpc.h>
#include <sys/types.h>

CLIENT *Clnt_create(const char *host, unsigned long prognum, unsigned long versnum, const char *protocol);
int
main()
{
int i,j,m,q,r,s;
CLIENT *cl;
mlt_in in;
mlt_out *outp;
cl = Clnt_create("127.0.0.1", MLT_PROG, MLT_VERS, "tcp");
printf("Insert dimension 1\n");
scanf("%i", q);
printf("\nInsert dimension 2\n");
scanf("%i", r);
printf("Insert indexes from 0 to 20");

for(i=0; i<20; i++)
{
scanf("%i", in.f[i]);
printf("%i\t", in.f[i]);
};

printf("Insert indexes from 0 to 20");
for(j=0; j<20; j++)
{
scanf("%i", in.g[j]);
printf("%i\t", in.g[j]);
};

if ((outp = mltproc_1(&in, cl)) == NULL)
printf("error occured");
printf("\n");
for(m=0; m<=(r+q);m++)
{
printf("%i\t", outp->d[m]);
};

exit(0);
}

server.c
Code:
#include "mlt.h"
#include <stdio.h>
#include <rpc/rpc.h>
#include <sys/types.h>


mlt_out *
mltproc_l_svc(mlt_in *inp, struct svc_req *rqstp)
{
static mlt_out out;
int k, i;
int s = 40;
for(k=0; k<=s;k++)
{
out.d[k]=0;
for(i=0; i<=k;i++)
{
out.d[k]=inp->f[i]*inp->g[k-i];
};
};

/*out.d[1] = inp->f[19] * inp->g[19];*/

return(&out);
}

# 2  
Old 01-06-2012
How exactly are you compiling it?
# 3  
Old 01-06-2012
1) each .c file:
gcc -c *.c (* - name of the file)
I receive .o files - no problems.
2) then
gcc client.o mlt_clnt.o mlt_xdr.o -o client -lnsl

Ofcourse before using gcc I use rpcgen:
rpcgen mlt.x
# 4  
Old 01-06-2012
Keep in mind that include files don't include libraries -- they only tell the compiler what functions ought to exist. So no matter how many include files you add, that will never resolve "undefined external" errors. "unresolved external" means more than one .c or .o file was required to completely build one executable, because they were using parts of each other -- or a library was missing.

You shouldn't be using raw gcc to build your RPC programs. There are many source files, some which need to be compiled together, some which shouldn't, and which belongs where kind of depends on what your RPC generator generated.

Usually you'd do this:

Code:
# Convert your template into code you can fill out.
# It also builds a makefile for you, which knows how to build your server
# and client programs.
rpcgen -a -C mlt.x
vim mlt_server.c # Edit your own code into mlt_server.c
vim mlt_client.c # Edit your own code into mlt_client.c
make -f Makefile.mlt mlt_client mlt_server

When I do that, I get:

Code:
$ make -f Makefile.mlt mlt_server mlt_client
make[1]: Entering directory `/home/username/code/c/1shot/rpc'
cc -g    -c -o mlt_svc.o mlt_svc.c
cc -g    -c -o mlt_server.o mlt_server.c
cc -g    -c -o mlt_xdr.o mlt_xdr.c
cc -g     -o mlt_server  mlt_svc.o mlt_server.o mlt_xdr.o -lnsl
cc -g    -c -o mlt_clnt.o mlt_clnt.c
cc -g    -c -o mlt_client.o mlt_client.c
cc -g     -o mlt_client  mlt_clnt.o mlt_client.o mlt_xdr.o -lnsl
make[1]: Leaving directory `/home/username/code/c/1shot/rpc'

$

So mlt_server needs mlt_svc.c, mlt_server.c, and mlt_xdr.c all at the same time.

And mlt_client needs mlt_clnt.c, mlt_client.c, and mlt_xdr.c all at the same time.

They also both need -lnsl.

---------- Post updated at 11:17 AM ---------- Previous update was at 11:13 AM ----------

Having done all of this, I finally see what the error is.

In the autogenerated code, I find:

Code:
clnt = clnt_create (host, MLT_PROG, MLT_VERS, "udp");

In your code, you have:

Code:
CLIENT *Clnt_create(const char *host, unsigned long prognum, unsigned long versnum, const char *protocol);

C function names are Case Sensitive.
# 5  
Old 01-06-2012
oh) thank u very much!
# 6  
Old 01-06-2012
You should not be declaring clnt_create, by the way. That's a library function. I'm guessing you did so to get around 'undeclared function' warnings, but the real problem wasn't that it was undeclared, but that it didn't exist at all...
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Solaris

How to add new Solaris client IP into Solaris 10 DNS server?

Hi, We just built a new Solaris 10 zone. And would like to add it to our DNS server. Its also Solaris 10. Please let me know how can I get the IP resolved using this DNS server. I added entry into zone config file but not working. I did restarted the DNS services. And also added nameserver name... (5 Replies)
Discussion started by: snchaudhari2
5 Replies

2. Solaris

LDAP server and client configuration in Solaris 10

How do i install ldap server and client in solaris server how to configure ldap server and client please help me (1 Reply)
Discussion started by: ainstin
1 Replies

3. Red Hat

Nfs client mount RPC Error: Program not registered.

Hello, I was having few issues on my linux box, I am getting this error whenever I tried to mount a share on a client linux host. # mount -t nfs 10.10.4.150:/data/pops_sva /mnt mount: mount to NFS server '10.10.4.150' failed: RPC Error: Program not registered. # I see the error and I... (4 Replies)
Discussion started by: bobby320
4 Replies

4. Solaris

Solaris syslog server and client

Hi folks, I am attempting to setup a Solaris 10 syslog server to receive logs from linux machines. Here's what I did: On the server (SunOS sun226 5.10), IP address: 192.168.212.226: 1. start syslogdby issuing $/usr/sbin/syslogd -T On a client (SunOS sun221 5.8): 1. Configured... (1 Reply)
Discussion started by: kimurayuki
1 Replies

5. Solaris

RPC: Rpcbind failure - RPC: Timed out error (solaris)

C: Rpcbind failure - RPC: Timed out error (solaris) hello an nfs server on my sun fire v440 is not responding , i get the error bellow and lots of my networking services are not reponding, please helppppp its an emergency RPC: Rpcbind failure - RPC: Timed out i also get NFS server... (2 Replies)
Discussion started by: feg
2 Replies

6. Programming

Client/Server Socket Application - Preventing Client from quitting on server crash

Problem - Linux Client/Server Socket Application: Preventing Client from quitting on server crash Hi, I am writing a Linux socket Server and Client using TCP protocol on Ubuntu 9.04 x64. I am having problem trying to implement a scenario where the client should keep running even when the... (2 Replies)
Discussion started by: varun.nagpaal
2 Replies

7. Linux

NFS Server FC7 Solaris client problems!

Hi, my problem is that I am not able to grand the nfs directory on a Fedora 7 server to a standard solaris client. I always got the messages no permission. Important: No change on the client (Solaris) is possible! So I am not able to change the NFS Version on the client side to force the... (3 Replies)
Discussion started by: joerg
3 Replies

8. Programming

Creating a client handle in RPC

Hi, I am trying to create a CLIENT handle in RPC on Solaris. I am calling the following function CLIENT *clnt = clnt_create(host, prognum, versnum, nettype); However If I call this in main it seems to work but if I call this function in any other function it fails with a segmentation... (1 Reply)
Discussion started by: pic
1 Replies
Login or Register to Ask a Question