APUE Study Notes-record 1, APUE Study Notes-record

Source: Internet
Author: User

APUE Study Notes-record 1, APUE Study Notes-record

It has been almost a week since we started to see APUE. It is rare that we will not be disturbed by the three-day free holiday because we have just caught up with the Tomb Sweeping Day holiday in the past few days, now that you have read the first six chapters, most of the routines are also compiled and debugged. However, I always thought that I would forget to learn this course. Therefore, I decided to record this learning process and review the previous chapter when I learned the next chapter. You can also record the problems you encounter during the learning process.

This book explains all aspects of the interfaces provided by UNIX systems, and introduces a lot of knowledge about UNIX or UNIX-like systems in the middle. Even though I have read the first six chapters, I also learned a lot of knowledge to solve some of my previous questions about LINUX. It is good to learn things you don't know every day.

This book provides all the routines of the Book, which can be obtained on this website: http://www.apuebook.com/code3e.html. I use the third edition. But I encountered a problem in the First Routine. After writing the program, compile the program and report the following error: $ gcc c1_3.c

/Tmp/cchudidN. o: In function 'main ':
Copyright 3.c :(. text + 0x20): undefined reference to 'err _ quit'
Container 3.c :(. text + 0x5b): undefined reference to 'err _ sys'
Collect2: ld returned 1 exit status

(The problem has been resolved and not recorded. Therefore, I reference this article and set the entire configuration environment according to this method;

Http://blog.csdn.net/blitzskies/article/details/42171089)

The err_quit and err_sys functions are both in apue. although referenced in the program, you must specify the referenced External library during gcc compilation. printf is the system library and has been specified in the environment variable, we do not need to specify. But where is the library we need? Now we need to go back to the downloaded apue file package, decompress the package, and there is a README in the file directory, which clearly says, make (The make command is used to keep a group of programs up to date, automatically process the work of those modules that need to be re-compiled due to the complex dependency between modules ). Then we will find the libapue. a file (.FileIs a static link library file in LINUX), which is the library file we need. Then we will introduce it into our LIBRARY_PATH environment variable, and the apue that we will reference in every routine program. h. It is in the include folder. We need to introduce it into the C_INCLUDE_PATH environment variable. The purpose of setting these two variables is to allow the program to find the library file and header file, and enter the command:

 

-Lapue is added every time you compile the program.

The running result is as follows:

The first chapter is the introduction to UNIX. All sections are described in detail later.

The second chapter focuses on the introduction of the UNIX standard and the implementation differences on different systems. There are several functions to tell you the limits actually supported on a specific system:

# Icnlude <unistd. h>

Long sysconf (int name );

Long pathconf (const char * pathname, int name );

Log fpathconf (int fd, int name );

The parameter name in the sysconf function is used to identify system restrictions. If the system supports this function, the corresponding value is returned, and-1 is returned for an error.

Pathconf and fpathconf are used to obtain the restriction of the name identifier on the file indicated by pathname. If the system supports this restriction, the corresponding value is returned, and-1 is returned if an error occurs.

If you do not know the system functions, you can use the man command to view them.

 

That's it...

 

Related Article

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.