Apue. h error in advanced programming in UNIX environment

Source: Internet
Author: User

I recently read Richard Stevens's masterpiece "Advanced Programming in UNIX environments". I believe that many people who read this book will encounter this problem like me. problems may occur when compiling program instances in the book, the error message "error: apue. h: The file or directory does not exist ".

Apue. H is a header file customized by the author. It is not included in Unix/Linux systems. This header file includes common header files required by UNIX programs and error handling functions written by Richard. Therefore, by default, GCC cannot read this header file during compilation.

First in this website http://www.apuebook.com/download tar.gz format source package, and then extract to a directory, such as/home/yarkee/, and then enter the directory apue.2e, the file make. defines. in Linux, change wkdir =/home/XXX/apue.2e to wkdir =/home/yarkee/apue.2e, then enter the STD directory under the apue.2e directory, and open Linux. MK, replace all the nawk in it with awk. If you are using the VI/Vim editor, you can use this command: 1. $ S/nawk/awk/g (note that there is a colon Before)
Then run the make command in this directory, that is, return to the/home/yarkee/apue.2e directory and enter "./make" (excluding quotation marks) in the terminal)

Then, put the apue in the/home/yarkee/apue.2e/inlcude directory. h file and error in the/home/yarkee/apue.2e/lib directory. copy all c files to the/usr/include directory. Note that you must have the root permission to copy these two files. This is because GCC searches for the required header file in the/usr/include directory when linking the header file. If no header file is found, an error is returned.

Finally, edit the copied apue. h file.
Add a line before the last line # endif # include "error. c"

In this way, no error is reported.

I recently read Richard Stevens's masterpiece "Advanced Programming in UNIX environments". I believe that many people who read this book will encounter this problem like me. problems may occur when compiling program instances in the book, the error message "error: apue. h: The file or directory does not exist ".

Apue. H is a header file customized by the author. It is not included in Unix/Linux systems. This header file includes common header files required by UNIX programs and error handling functions written by Richard. Therefore, by default, GCC cannot read this header file during compilation.

First in this website http://www.apuebook.com/download tar.gz format source package, and then extract to a directory, such as/home/yarkee/, and then enter the directory apue.2e, the file make. defines. in Linux, change wkdir =/home/XXX/apue.2e to wkdir =/home/yarkee/apue.2e, then enter the STD directory under the apue.2e directory, and open Linux. MK, replace all the nawk in it with awk. If you are using the VI/Vim editor, you can use this command: 1. $ S/nawk/awk/g (note that there is a colon Before)
Then run the make command in this directory, that is, return to the/home/yarkee/apue.2e directory and enter "./make" (excluding quotation marks) in the terminal)

Then, put the apue in the/home/yarkee/apue.2e/inlcude directory. h file and error in the/home/yarkee/apue.2e/lib directory. copy all c files to the/usr/include directory. Note that you must have the root permission to copy these two files. This is because GCC searches for the required header file in the/usr/include directory when linking the header file. If no header file is found, an error is returned.

Finally, edit the copied apue. h file.
Add a line before the last line # endif # include "error. c"

In this way, no error is reported.

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.