Unix Network Programming (Volume 2) source code compilation error solution.

Source: Internet
Author: User

 

Download location: http://www.kohala.com/start/unpv22e/unpv22e.html

1. Follow the Readme operation to go To the lib directory and run make to report an error:

 

 

Gcc-g-O2-D_REENTRANT-Wall-D_POSIX_PTHREAD_SEMANTICS-c-o daemon_inetd.o daemon_inetd.c

In file encoded ded from/usr/include/netinet/in. h: 24,

From/usr/include/rpc/types. h: 90,

From/usr/include/rpc. h: 38,

From unpipc. h: 115,

From daemon_inetd.c: 1:

/Usr/include/stdint. h: 49: error: duplicate 'unsigned'

/Usr/include/stdint. h: 49: error: two or more data types in declaration specifiers

/Usr/include/stdint. h: 50: Error: duplicate 'unsigned'

/Usr/include/stdint. h: 50: Error: duplicate 'shport'

/Usr/include/stdint. h: 52: Error: duplicate 'unsigned'

/Usr/include/stdint. h: 52: Error: two or more data types in Declaration specifiers

Make: *** [daemon_inetd.o] Error 1

 

Modify config. h and comment out the following three lines:

 

// # Define uint8_t unsigned char/* <sys/types. h> */

// # Define uint16_t unsigned short/* <sys/types. h> */

// # Define uint32_t unsigned int/* <sys/types. h> */

2. Link error: an error is reported when the generated libunpipc. A is linked to our C program.

 

 

./Libunpipc. A (wrapunix. O): In function 'mktemp ':

/Home/vonnyfly/Document/unix_src/unpv22e/lib/wrapunix. c: 184: warning: the use of 'mktemp 'is dangerous, better use 'mkstemp' or 'mkdtemp'

/Tmp/javasndn2n. o: In function 'main ':

Mqcreate1.c :(. text + 0x3a): undefined reference to 'getopt'

./Libunpipc. a (wrapunix. o): In function 'shm _ unlink ':

Wrapunix. c :(. text + 0x54d): undefined reference to 'shm _ unlink'

./Libunpipc. a (wrapunix. o): In function 'shm _ open ':

Wrapunix. c :(. text + 0x58c): undefined reference to 'shm _ open'

./Libunpipc. a (wrapunix. o): In function 'sem _ getvalue ':

Wrapunix. c :(. text + 0x6d4): undefined reference to 'sem _ getvalue'

./Libunpipc. a (wrapunix. o): In function 'sem _ Post ':

Wrapunix. c :(. text + 0x6fd): undefined reference to 'sem _ Post'

./Libunpipc. a (wrapunix. o): In function 'sem _ trywait ':

Wrapunix. c :(. text + 0x72e): undefined reference to 'sem _ trywait'

./Libunpipc. a (wrapunix. o): In function 'sem _ wait ':

Wrapunix. c :(. text + 0x77d): undefined reference to 'sem _ wait'

./Libunpipc. a (wrapunix. o): In function 'sem _ destroy ':

Wrapunix. c :(. text + 0x7ad): undefined reference to 'sem _ destroy'

./Libunpipc. a (wrapunix. o): In function 'sem _ init ':

Wrapunix. c :(. text + 0x7eb): undefined reference to 'sem _ init'

./Libunpipc. a (wrapunix. o): In function 'sem _ unlink ':

Wrapunix. c :(. text + 0x81d): undefined reference to 'sem _ unlink'

./Libunpipc. a (wrapunix. o): In function 'sem _ close ':

Wrapunix. c :(. text + 0x84d): undefined reference to 'sem _ close'

./Libunpipc. a (wrapunix. o): In function 'sem _ open ':

Wrapunix. c :(. text + 0x897): undefined reference to 'sem _ open'

Wrapunix. c :(. Text + 0x8b0): Undefined reference to 'sem _ open'

./Libunpipc. A (wrapunix. O): In function 'mq _ setattr ':

Wrapunix. c :(. Text + 0 xbeb): Undefined reference to 'mq _ setattr'

./Libunpipc. A (wrapunix. O): In function 'mq _ getattr ':

Wrapunix. c :(. Text + 0xc24): Undefined reference to 'mq _ getattr'

./Libunpipc. A (wrapunix. O): In function 'mq _ Policy ':

Wrapunix. c :(. Text + 0xc54): Undefined reference to 'mq _ Policy'

./Libunpipc. A (wrapunix. O): In function 'mq _ receive ':

Wrapunix. c :(. Text + 0xc92): Undefined reference to 'mq _ receive'

./Libunpipc. A (wrapunix. O): In function 'mq _ send ':

Wrapunix. c :(. Text + 0xce2): Undefined reference to 'mq _ send'

./Libunpipc. A (wrapunix. O): In function 'mq _ unlink ':

Wrapunix. c :(. Text + 0xd0d): Undefined reference to 'mq _ unlink'

./Libunpipc. a (wrapunix. o): In function 'mq _ close ':

Wrapunix. c :(. text + 0xd3d): undefined reference to 'mq _ close'

./Libunpipc. a (wrapunix. o): In function 'mq _ open ':

Wrapunix. c :(. text + 0xd79): undefined reference to '_ mq_open_2'

Wrapunix. c :(. text + 0xd9e): undefined reference to 'mq _ open'

Collect2: ld returned 1 exit status

 

 

Solution: add the-lrt Command Option to gcc (for details, see man mq_open)

3. GetOpt not found:

 

/Tmp/ccv1UEy3. o: In function 'main ':

Mqcreate1.c :(. text + 0x3a): undefined reference to 'getopt'

Collect2: ld returned 1 exit status

It's okay to directly change the program to getopt.

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.