I have sorted out a FAQ, and a FAQ for beginners.

Source: Internet
Author: User
Tags gtk tru64

I sorted out a FAQ and asked the newbie to take a look-a quiet dog-blog Garden

I have compiled a FAQ for beginners to take a look.
I. Unix/Linux environment

Q: I want to learnProgramWhat language should I use for design? What books should I read?
A: C should be preferred. Most of the software running on UNIX itself and on it is written in C. The UNIX operating system API (System Call) interface is also provided in the form of a C function. There are two books that must be read: the second edition of C programming language, and the advanced programming of Unix environment. These two books contain too much gold. We recommend you buy a printed version.

Q: Why is "segment error?
A: A segment error occurs during the program running (segmentation fault) because of memory access violations. For example, if a read or write block is not allocated to you, write the memory with the read-only attribute, and so on. Beginners may make the following mistakes:

1 struct student {
2 int age;
3. Char name [128];
4 int score;
5 };
6
7 struct student * P;
8 p->; age = 21;/* error! The student structure has not been instantiated yet and no space has been allocated */

Change row 7th:
Struct student;
Struct student * P = &

Q: I wrote a Unix applet, but an error is reported during compilation, saying that the function is not declared?
A: You should use the "Man function name" to include the header file in the Program.

Q: I'm in solaries/AIX/HP-UX/IRIX/Tru64 ...... Why does the compilation report an error and the function definition cannot be found?
A: You should specify the database to be connected during compilation. For example, if the standard C library is used in the program,-LM is added. If the POSIX thread library is used,-lpthread is added. If the socket function is used, -lsocket is added. If POSIX real-time extension library is used,-LRT is added.
In addition, during GCC compilation on Linux, some system libraries are automatically searched. For example, you can use GCC to compile the socket program on Linux without specifying-lsocket, but unfortunately: 1) not all databases are valid. For example, a math database is not automatically added. 2) Not all unix cc instances provide this feature.

Q: I have compiled a program and specified to connect to a database. Why not?
A: If your header files and library files are not in the standard search path, you must specify them during compilation.

For example, my MySQL is installed under/usr/local/MySQL/, and the header file is under/usr/local/MySQL/include/MySQL, the library file is under/usr/local/MySQL/lib/MySQL/. to connect to the library mysqlclient, the compilation option is as follows:
Cflags =-wall-g-I/usr/local/MySQL/include/MySQL-L/usr/local/MySQL/lib/MySQL-lmysqlclient

Q: I have compiled the program according to the above format and passed it. I cannot find the shared library when it is run?
A: In the above example, information about the library path is added to the generated executable file. Therefore, if your library file is not in the standard path, you can: 1) copy it to/usr/lib/, if this library is very common; 2) Modify/etc/lD. so. CONF file, add the full path of the library, and run ldconfig; 3) Export LD_LIBRARY_PATH = $ LD_LIBRARY_PATH: Your-path, if this library is not commonly used.

Q: What should I do if I want to learn how to write makefile?
A: For details about how to write makefile with me, see.

Q: What should I do if I want to learn GDB?
A: Use GDB to debug programs is available in the essence of this edition. For more information, see.

II. VI/Vim
(If not specified, it is called vim. In addition, it only indicates what is not mentioned in vimtutor, but it is more practical. For details, refer to the pin post of the FLW Moderator and the Chinese manual provided below)

Q: What is the difference between VI and Vim?
A: VI refers to visual, which is accompanied by the editor of almost the original Unix release version; VIM refers to VI improved, that is, enhanced version of VI. Vim is recommended.

Q: Where can I find Vim's Chinese manual?
A: Vim User Manual:
Http://vcd.gro.clinux.org/
Vim Help manual:
Http://vimcdoc.sf.net.

Q: How can I move the cursor up, down, and left in Vim?
A: Run vimtutor. It will teach you how to use the most basic functions of vim.

Q: How do I enter the man manual in Vim?
A: move the cursor to the function name, and press K in upper case to go to the start page.

Q: But I put the cursor on printf and press K to go To the bash printf manual?
A: printf is a C-library function, which is the third part of the book page. Enter 3 first, and then press K. If it is a system call (such as a kill function), enter 2 and then press K.

Q: I want to know the type defined by a system, such as the real definition of stat. How can this problem be solved?
A: Run PS stat in Vim. It will automatically search for the real definition of this type for you.

Q: What should I do if I want to learn many of Vim's powerful functions?
A: refer to the top posts of the FLW moderator,
Http://bbs.chinaunix.net/forum/viewtopic.php? T = 472608

3. Good Book recommendations(Unless otherwise stated, it is published by the machinery industry)

4.1. C Language

Q: I am a beginner in C language. What books should I read?
A: We recommend that you read the second edition of "C Programming Tutorial" By Tan haoqiang. (Tsinghua University Press)

Q: What books should I read when I want to learn more about the C language?
A: The second edition of K & R's C programming language is required. In addition, we recommend "program design practice" (the mechanical industry has a printing plate), "C language interface and implementation", "C expert programming" (People's post and telecommunications), and "C: traps and defects (People's post and telecommunications), as well as learning programming from the work of Steven S.

Q: What books should I read when I want to become a master of C language?
A: Sorry, I am not qualified to answer this question.

4.2. Data Structure andAlgorithmArticle
Q: What books should I read if I have a great deal of data structures and algorithms?

A: We recommend the second version of "data structure and algorithm-C language description" by Yan Weimin. (Tsinghua University Press)

Q: What books should I read to learn more about data structures and algorithms?
A: We recommend the second version of "data structure and algorithm analysis-C language description" by Mark Allen Weiss.

Q: What books should I read if I want to know all the data structures and algorithms that excellent programmers should learn?
A: We recommend Robert Sedgewick to publish the algorithm in the third edition. Algorithms in C is published in China Electric Power. (Note: I am ashamed to say that this book is based on the recommendations of cool people. I have not read several pages yet)

4.3. Unix/Linux Programming

Q: I want to learn programming in Unix/Linux. Is there a book dedicated to this?
A: Steven's advanced programming for UNIX environments is an irreplaceable masterpiece in this field. Please read it carefully. (Printing plates are also published by the machinery industry)

Q: What books do I want to learn about socket programming in Unix/Linux?
A: The two-volume UNIX Network Programming (version 2) of Steven s is an irreplaceable masterpiece in this field. Please read it carefully. Both are published by Tsinghua University Press (both have photocopies, and both are published by Tsinghua University; among them, Volume 1 is the third edition, and the mechanical industry is published in more detail)

4.4. C ++

Q: What are the typical books in C ++?
A: This problem is too big. Please refer to the excellent post of whyglinux hero:
Http://bbs.chinaunix.net/forum/viewtopic.php? T = 321401

4. C ++

Q: Why are errors reported in my hello World programs?
A: Use the G ++ command to compile the C ++ program and use the GCC command to compile the C program-they differ in the final determination of the library to be connected.

Q: Why is the error "cout undefined" reported when I write a small program "?
A: Add using namespace STD after all include in the program. In addition, we recommend that you read some "Standard C ++" documents.

Q: Why is an error reported when I compile a program in VC?
A: I don't know what's going on. I don't know the VC version or the MFC and ATL of vc6 as the development framework, but I know that the vc6 compiler is very junk. If you must learn C ++ in windows, Dev-C ++ is recommended.

Q: I used Dev-C ++ to compile the program, but the runtime flashed over. How can I stop the screen?
A: add system ("pause"); or CIN. Get (); before the main function returns ();.

5. Miscellaneous

Q: Should I learn Java or C ++?
A: I don't know.

Q: Which of the following is more powerful for vim and Emacs?
A: I don't know.

Q: Where can I download Unix/Linux and C/C ++ e-books?
A: refer to the top posts of Lenovo moderators of this version.

Q: Do I need to be proficient in English?
A: English is the native language of programmers. I personally think it should at least reach this level: the original work of Dr. Steven S is unobstructed.

Q: Where are the materials used to explain various knowledge?
A: Google does. If you want to find a software, enter a name, and click "good luck", it will go directly to the main site. If you want to find information in a specific field, enter the name, and add "filetype: PDF", you can find many PDF documents.

Q: Should I use a process or a thread?
A: specific analysis of the problem. The essence of this edition includes a discussion of Thread/process performance.

Q: Where are Unix/Linux functions?
A: Man manual is your best mentor.

Q: What should I do if I want to learn about Linux interface programming?
A: ncurse, GTK +/gtkmm/glade, QT, Motif ...... Can, it is recommended to go to the rapid development of http://www.linuxforum.net version to download information, learning.

Q: What should I do if apue is hard to understand?
A: To be honest, I am not qualified to answer this question, because I cannot understand it in many places. But generally from Chapter 1 to Chapter 14th (except Chapter 11th ?) I should always read it carefully, write a program test, and understand the English version of the Chinese version according to the English version. Apue has been deeply written, and some of the content is indeed outdated (after all, it was the second version of the book in 1992, and the second version has been released in the United States), which is in conflict with the existing OS, but it is still an authoritative book on Unix programming.

Q: here we will talk about apue, UNP, K & R, tcpl, tcpvx ,......, What is it?
A: apue, advanced programming in the Unix environment, advanced programming in the Unix environment;
UNP, UNIX network programming, and UNIX network programming;
K & R, Brian kernighan and Dennis Ritchie, the C programming language, C programming language;
Tcpl, the C ++ programming language, C ++ programming language;
D & E, the design and evolution of C ++, C ++ language design and evolution;
Tcpv1, TCP/IP volume strated Volume I, TCP/IP volume 1;
......

Q: Why can't the compiler find the ITOA function?
A: because it is not a standard function, the introduction of this function is simply an extra move. Use sprintf.

Q: What kind of good memory leak detection tools are available in Unix/Linux?
A: No. It is said that dmalloc is good.

Q: Will the process release space when exiting?
A: Yes. If only one process is in use for a block of memory, the block of memory will be released unconditionally at the end of the process, whether it is to call exit or return from main and exit normally or be killed by a signal.

Q: Where can I find the thread pool?Code?
A: Chapter 1 of the UNPv1-2nd has two thread pool instances (Chapter 3rd in Chapter 27th ). This kind of waiting asynchronous event (such as the return of the accept function) is the main use of the thread pool. In addition, there is also a kind of signal-driven, such as a timer-based thread pool. For more information about the next one, see the demo program of me ):
Http://bbs.chinaunix.net/forum/viewtopic.php? T = 536596


I. Unix/Linux environment

Q: What language should I use to learn programming in Unix/Linux? What books should I read?
A: C should be preferred. Most of the software running on UNIX itself and on it is written in C. The UNIX operating system API (System Call) interface is also provided in the form of a C function. There are two books that must be read: the second edition of C programming language, and the advanced programming of Unix environment. These two books contain too much gold. We recommend you buy a printed version.

Q: Why is "segment error?
A: A segment error occurs during the program running (segmentation fault) because of memory access violations. For example, if a read or write block is not allocated to you, write the memory with the read-only attribute, and so on. Beginners may make the following mistakes:

1 struct student {
2 int age;
3. Char name [128];
4 int score;
5 };
6
7 struct student * P;
8 p->; age = 21;/* error! The student structure has not been instantiated yet and no space has been allocated */

Change row 7th:
Struct student;
Struct student * P = &

Q: I wrote a Unix applet, but an error is reported during compilation, saying that the function is not declared?
A: You should use the "Man function name" to include the header file in the Program.

Q: I'm in solaries/AIX/HP-UX/IRIX/Tru64 ...... Why does the compilation report an error and the function definition cannot be found?
A: You should specify the database to be connected during compilation. For example, if the standard C library is used in the program,-LM is added. If the POSIX thread library is used,-lpthread is added. If the socket function is used, -lsocket is added. If POSIX real-time extension library is used,-LRT is added.
In addition, during GCC compilation on Linux, some system libraries are automatically searched. For example, you can use GCC to compile the socket program on Linux without specifying-lsocket, but unfortunately: 1) not all databases are valid. For example, a math database is not automatically added. 2) Not all unix cc instances provide this feature.

Q: I have compiled a program and specified to connect to a database. Why not?
A: If your header files and library files are not in the standard search path, you must specify them during compilation.

For example, my MySQL is installed under/usr/local/MySQL/, and the header file is under/usr/local/MySQL/include/MySQL, the library file is under/usr/local/MySQL/lib/MySQL/. to connect to the library mysqlclient, the compilation option is as follows:
Cflags =-wall-g-I/usr/local/MySQL/include/MySQL-L/usr/local/MySQL/lib/MySQL-lmysqlclient

Q: I have compiled the program according to the above format and passed it. I cannot find the shared library when it is run?
A: In the above example, information about the library path is added to the generated executable file. Therefore, if your library file is not in the standard path, you can: 1) copy it to/usr/lib/, if this library is very common; 2) Modify/etc/lD. so. CONF file, add the full path of the library, and run ldconfig; 3) Export LD_LIBRARY_PATH = $ LD_LIBRARY_PATH: Your-path, if this library is not commonly used.

Q: What should I do if I want to learn how to write makefile?
A: For details about how to write makefile with me, see.

Q: What should I do if I want to learn GDB?
A: Use GDB to debug programs is available in the essence of this edition. For more information, see.

II. VI/Vim
(If not specified, it is called vim. In addition, it only indicates what is not mentioned in vimtutor, but it is more practical. For details, refer to the pin post of the FLW Moderator and the Chinese manual provided below)

Q: What is the difference between VI and Vim?
A: VI refers to visual, which is accompanied by the editor of almost the original Unix release version; VIM refers to VI improved, that is, enhanced version of VI. Vim is recommended.

Q: Where can I find Vim's Chinese manual?
A: Vim User Manual:
Http://vcd.gro.clinux.org/
Vim Help manual:
Http://vimcdoc.sf.net.

Q: How can I move the cursor up, down, and left in Vim?
A: Run vimtutor. It will teach you how to use the most basic functions of vim.

Q: How do I enter the man manual in Vim?
A: move the cursor to the function name, and press K in upper case to go to the start page.

Q: But I put the cursor on printf and press K to go To the bash printf manual?
A: printf is a C-library function, which is the third part of the book page. Enter 3 first, and then press K. If it is a system call (such as a kill function), enter 2 and then press K.

Q: I want to know the type defined by a system, such as the real definition of stat. How can this problem be solved?
A: Run PS stat in Vim. It will automatically search for the real definition of this type for you.

Q: What should I do if I want to learn many of Vim's powerful functions?
A: refer to the top posts of the FLW moderator,
Http://bbs.chinaunix.net/forum/viewtopic.php? T = 472608

3. Good Book recommendations(Unless otherwise stated, it is published by the machinery industry)

4.1. C Language

Q: I am a beginner in C language. What books should I read?
A: We recommend that you read the second edition of "C Programming Tutorial" By Tan haoqiang. (Tsinghua University Press)

Q: What books should I read when I want to learn more about the C language?
A: The second edition of K & R's C programming language is required. In addition, we recommend "program design practice" (the mechanical industry has a printing plate), "C language interface and implementation", "C expert programming" (People's post and telecommunications), and "C: traps and defects (People's post and telecommunications), as well as learning programming from the work of Steven S.

Q: What books should I read when I want to become a master of C language?
A: Sorry, I am not qualified to answer this question.

4.2. Data Structure and Algorithm
Q: What books should I read if I have a great deal of data structures and algorithms?

A: We recommend the second version of "data structure and algorithm-C language description" by Yan Weimin. (Tsinghua University Press)

Q: What books should I read to learn more about data structures and algorithms?
A: We recommend the second version of "data structure and algorithm analysis-C language description" by Mark Allen Weiss.

Q: What books should I read if I want to know all the data structures and algorithms that excellent programmers should learn?
A: We recommend Robert Sedgewick to publish the algorithm in the third edition. Algorithms in C is published in China Electric Power. (Note: I am ashamed to say that this book is based on the recommendations of cool people. I have not read several pages yet)

4.3. Unix/Linux Programming

Q: I want to learn programming in Unix/Linux. Is there a book dedicated to this?
A: Steven's advanced programming for UNIX environments is an irreplaceable masterpiece in this field. Please read it carefully. (Printing plates are also published by the machinery industry)

Q: What books do I want to learn about socket programming in Unix/Linux?
A: The two-volume UNIX Network Programming (version 2) of Steven s is an irreplaceable masterpiece in this field. Please read it carefully. Both are published by Tsinghua University Press (both have photocopies, and both are published by Tsinghua University; among them, Volume 1 is the third edition, and the mechanical industry is published in more detail)

4.4. C ++

Q: What are the typical books in C ++?
A: This problem is too big. Please refer to the excellent post of whyglinux hero:
Http://bbs.chinaunix.net/forum/viewtopic.php? T = 321401

4. C ++

Q: Why are errors reported in my hello World programs?
A: Use the G ++ command to compile the C ++ program and use the GCC command to compile the C program-they differ in the final determination of the library to be connected.

Q: Why is the error "cout undefined" reported when I write a small program "?
A: Add using namespace STD after all include in the program. In addition, we recommend that you read some "Standard C ++" documents.

Q: Why is an error reported when I compile a program in VC?
A: I don't know what's going on. I don't know the VC version or the MFC and ATL of vc6 as the development framework, but I know that the vc6 compiler is very junk. If you must learn C ++ in windows, Dev-C ++ is recommended.

Q: I used Dev-C ++ to compile the program, but the runtime flashed over. How can I stop the screen?
A: add system ("pause"); or CIN. Get (); before the main function returns ();.

5. Miscellaneous

Q: Should I learn Java or C ++?
A: I don't know.

Q: Which of the following is more powerful for vim and Emacs?
A: I don't know.

Q: Where can I download Unix/Linux and C/C ++ e-books?
A: refer to the top posts of Lenovo moderators of this version.

Q: Do I need to be proficient in English?
A: English is the native language of programmers. I personally think it should at least reach this level: the original work of Dr. Steven S is unobstructed.

Q: Where are the materials used to explain various knowledge?
A: Google does. If you want to find a software, enter a name, and click "good luck", it will go directly to the main site. If you want to find information in a specific field, enter the name, and add "filetype: PDF", you can find many PDF documents.

Q: Should I use a process or a thread?
A: specific analysis of the problem. The essence of this edition includes a discussion of Thread/process performance.

Q: Where are Unix/Linux functions?
A: Man manual is your best mentor.

Q: What should I do if I want to learn about Linux interface programming?
A: ncurse, GTK +/gtkmm/glade, QT, Motif ...... Can, it is recommended to go to the rapid development of http://www.linuxforum.net version to download information, learning.

Q: What should I do if apue is hard to understand?
A: To be honest, I am not qualified to answer this question, because I cannot understand it in many places. But generally from Chapter 1 to Chapter 14th (except Chapter 11th ?) I should always read it carefully, write a program test, and understand the English version of the Chinese version according to the English version. Apue has been deeply written, and some of the content is indeed outdated (after all, it was the second version of the book in 1992, and the second version has been released in the United States), which is in conflict with the existing OS, but it is still an authoritative book on Unix programming.

Q: here we will talk about apue, UNP, K & R, tcpl, tcpvx ,......, What is it?
A: apue, advanced programming in the Unix environment, advanced programming in the Unix environment;
UNP, UNIX network programming, and UNIX network programming;
K & R, Brian kernighan and Dennis Ritchie, the C programming language, C programming language;
Tcpl, the C ++ programming language, C ++ programming language;
D & E, the design and evolution of C ++, C ++ language design and evolution;
Tcpv1, TCP/IP volume strated Volume I, TCP/IP volume 1;
......

Q: Why can't the compiler find the ITOA function?
A: because it is not a standard function, the introduction of this function is simply an extra move. Use sprintf.

Q: What kind of good memory leak detection tools are available in Unix/Linux?
A: No. It is said that dmalloc is good.

Q: Will the process release space when exiting?
A: Yes. If only one process is in use for a block of memory, the block of memory will be released unconditionally at the end of the process, whether it is to call exit or return from main and exit normally or be killed by a signal.

Q: Where can I find the code of the thread pool?
A: Chapter 1 of the UNPv1-2nd has two thread pool instances (Chapter 3rd in Chapter 27th ). This kind of waiting asynchronous event (such as the return of the accept function) is the main use of the thread pool. In addition, there is also a kind of signal-driven, such as a timer-based thread pool. For more information about the next one, see the demo program of me ):
Http://bbs.chinaunix.net/forum/viewtopic.php? T = 536596

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.