Linux programmers often encounter problems with Linux novices, and today lists the most common programming errors encountered by novices, and provides solutions for them:
1) because it is a new Linux novice, it is now beginning to touch threading programming, according to an example in the Gun/linux Programming Guide to enter the compilation, resulting in the following error:
Undefined reference to ' pthread_create '
Undefined reference to ' Pthread_join '
Cause of the problem:
The Pthread library is not the default library for Linux systems and requires static library LIBPTHREAD.A when connecting, so when creating a thread with pthread_create () and calling the Pthread_atfork () function to set up a fork handler, You need to link to the library.
Problem solving:
Add the-lpthread parameter to the compilation
Gcc-o Thread Thread.c-lpthread
THREAD.C for you some of the source files, don't forget to add header file # # #
(2) Warning: Implicit declaration of strlen incompatible with built-in function, implicit declaration of an incompatible exit of the built-in function
Cause of the problem: because the function strlen within a string, exit is within Stdlib. Header file not added in file string.h and Stdlib
Problem solving: Adding header files to files String.h and stdlib
(3) Error occurred: sem_union storage size is unknown
Problem reason: In the new 2.6 kernel about Union sem_union This consortium has been annotated and needs to write the consortium itself
Problem solving: Define in C file first
Union Semun {int val; struct Semid_ds *buf; unsigned short *array;} Sem_union;
It will then be able to find a pre-defined Sem_union consortium at compile time.
Common errors and solutions for Linux programming