No users logged in to rpc

I am new to rpc ie iam at the training stage, I want none of the users to log in from the program below and I compiled like this "cc samrpc.c -lrpcsvc", but the error and warning that it showed were

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 

Can I tell you in detail how to compile the program, and wat are the requirements that I need to note: samrpc.c is the name of the program, my program is below

  #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; } 

}

+4
source share
1 answer

Check your code

ld returns 1 exit status means that you have an undefined reference to your main function. Because of this, the linker cannot find the entry point to the program

Your main code was not defined correctly; your run-time argument was not sent correctly either

 #include <stdio.h> #include<process.h> int main(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; } 

Define a basic structure and it should work

-1
source

All Articles