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.