Learning UNP Network programming, tree examples exist #include "unp.h", it is necessary to configure the environment.
1. Download unpv13e to the resource page
2. Extract and move unpv13e to the appropriate folder
3. Compile
>$ CD unpv13e
>~unpv13e/$./configure
>~unpv13e/$ cd lib
>~unpv13e/lib/$ make
>~ unpv13e/lib/$ CD ... /libfree
>~unpv13e/libfree/$ Make
If the following problems occur:
Gcc-i.. /lib-g-o2-d_reentrant-wall -c-o inet_ntop.o inet_ntop.c inet_ntop.c:in
function ' inet_ntop ':
inet_ntop . C:60:9: error:argument ' size ' doesn ' t match prototype
size_t size;
^ in
file included from inet_ntop.c:27:0:
/usr/include/arpa/inet.h:64:20:error:prototype declaration
extern const char *inet_ntop (int __af, const void *__restrict __cp,
^ make
: * * * [INET_NTOP.O] Error 1
You need to:
>~unpv13e/libfree/$ vim inet_ntop.c //Change the size_t size of line 60th to socklen_t size;
>~unpv13e/libfree/$ make//change and make
>~unpv13e/libfree/$ CD again. /libgai
>~unpv13e/libgai/$ make //below is just warning, slightly
/usr/include/arpa/inet.h:in function ' Inet_ntop ' :
inet_ntop.c:152:23:warning: ' Best.len ' May is used uninitialized in this function [-wmaybe-uninitialized]
if ( Best.base = = 1 | | Cur.len > Best.len)
^
inet_ntop.c:123:28:note: ' Best.len ' is declared here
struct {int base, Len;} BES T, cur;
^
Gcc-i. /lib-g-o2-d_reentrant-wall -c-o inet_pton.o inet_pton.c
ar rv. /libunp.a in_cksum.o inet_ntop.o inet_pton.o
a-in_cksum.o a-inet_ntop.o-a-inet_pton.o ranlib
. /libunp.a
At this point, the compilation succeeded in generating a static library Libunp.a
4. Copy the generated libunp.a to the/usr/lib
>~unpv13e/libgai/$ CD ...
>~unpv13e/$ sudo cp libunp.a/usr/lib
5. Modify Unpv13e/lib/unp.h and copy
>~unpv13e/$ vim lib/unp.h //Will #include ". /config.h "changed to #include" Config.h "
>~unpv13e/$ sudo cp lib/unp.h/usr/include
>~unpv13e/$ sudo cp Config.h/usr/include
6. Compiling examples
>~unpv13e/$ CD intro
>~unpv13e/$ gcc daytimetcpcli.c-o CLI-LUNP
The success of the compilation is accomplished.