我是 rpc 的新手,即 iam 处于学习阶段我想找出从以下程序登录的用户的数量,我像这样编译“cc samrpc.c -lrpcsvc”,但它显示的错误和警告是
samrpc.c: In function ‘main’:
samrpc.c:9:1: warning: incompatible implicit declaration of built-in function ‘exit’ [enabled by default]
samrpc.c:13:1: warning: incompatible implicit declaration of built-in function ‘exit’ [enabled by default]
/tmp/ccxyIUNJ.o: In function `main':
samrpc.c:(.text+0x51): undefined reference to `rnusers'
collect2: error: ld returned 1 exit status
你能详细告诉我如何编译程序吗?我需要注意的是:samrpc.c 是程序名称,我的程序在下面
#include <stdio.h>
int main(argc, argv)
int argc;
char **argv;
{
int num;
if (argc != 2) {
fprintf(stderr, "usage: rnusers hostname\n");
exit(1);
}
if ((num = rnusers(argv[1])) < 0) {
fprintf(stderr, "error: rnusers\n");
exit(-1);
}
printf("%d users on %s\n", num, argv[1]);
return 0;
}
}