"UNP" UNIX Network Programming volume 1--> Environment Building (ubuntu14.04)

Source: Internet
Author: User

Learn UNP network programming, the tree examples are there "unp.h", it is necessary to configure the environment.

1. To the Resources page download unpv13e

2. Unzip and move the unpv13e to the appropriate folder

3. Compiling

1 >$ cd unpv13e   2 >~unpv13e/$./Configure  3   4 >~unpv13e/$ cd lib  5make  6   7 >~ unpv13e/lib/$ CD. /libfree  8 make  

If the following issues occur:

1 GCC-I.. /lib-g-o2-d_reentrant-wall-c-o inet_ntop.o inet_ntop.c2Inet_ntop.c:infunction' inet_ntop ':3INET_NTOP.C: -:9: error:argument ' size ' doesn ' t match prototype4 size_t size; 5^6InchfileIncluded from INET_NTOP.C: -:0:  7/usr/include/arpa/inet.h: -: -: Error:prototype Declaration8extern constChar*inet_ntop (int__AF, const void *__restrict __CP,9^Ten  Make: * * * [INET_NTOP.O] Error1  

You will need:

1>~unpv13e/libfree/$ Vim Inet_ntop.c//Change the size_t size of line 60th to socklen_t size; 2>~unpv13e/libfree/$ Make //re -make when the change is complete3>~unpv13e/libfree/$ CD. /Libgai4>~unpv13e/libgai/$ Make   //The following is only warning, slightly5/usr/include/arpa/inet.h:infunction' inet_ntop ':6INET_NTOP.C: the: at: Warning: ' Best.len ' may used uninitializedinchThisfunction[-wmaybe-Uninitialized]7    if(Best.base = =-1|| Cur.len >Best.len)8^9INET_NTOP.C:123: -: Note: ' Best.len ' was declared hereTenstruct {intbase, Len;}  Best, cur;  One^ A GCC-I.. /lib-g-o2-d_reentrant-wall-c-o inet_pton.o inet_pton.c - arRv.. /libunp.a in_cksum.o INET_NTOP.O inet_pton.o -AIN_CKSUM.O theAINET_NTOP.O -AINET_PTON.O -Ranlib. /libunp.a

At this point, the compilation succeeded in generating the static library Libunp.a

4. Copy the generated libunp.a to/usr/lib

1 >~unpv13e/libgai/$ cd   . 2 sudo CP Libunp.a/usr/lib  


5. Modify the Unpv13e/lib/unp.h and copy

1 >~unpv13e/$ vim lib/unp.h  //  will include ". /config.h "changed to #include" Config.h "  2 >~unpv13e/$  sudocp lib/unp.h/usr/ include   3 sudo CP Config.h/usr/include  


6. Compiling examples

1 >~unpv13e/$  cd intro  2 >~unpv13e/$  gcc Daytimetcpcli.c-o CLI-LUNP  



The compilation succeeds.

UNP UNIX Network Programming volume 1--> Environment Build (ubuntu14.04)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.