Learning UNIX Advanced Programming
1. Download the source code from www.apuebook.com.
2.tar unpack, CD apue.2e
3. VI make. Defines. Linux: Modify the variable wkdir to point to the location of your apue source code. my options are/home/huangz/code/apue.2e, so
Wkdir =/home/huangz/code/apue.2e
4. VI Include/apue. h adds a constant arg_max, which is used by threadctl/getenv1.c and threadctl/getenv3.c. The value 4096 is provided in reference. If there is any problem, modify it.
# Define arg_max 4096
5. Added VI threadctl/getenv1.c.
# Include "apue. H"
6. Added VI threadctl/getenv3.c.
# Include "apue. H"
7. Modify row 31st by VI threads/badexit2.c and convert the return value of pthread_self () to the int type.
Printf ("thread 2: ID is % d \ n", (INT) pthread_self ());
Http://blog.csdn.net/ce_endless/article/details/6885708
9. Make
10. sudo CP include/apue. h/usr/include
Sudo CP lib/libapue. A/usr/lib
Okay. Test it. Remember to use the-lapue command to connect the compiler to the apue library.
GCC main. C-lapue
Compile and run the program
GCC source program. C-o executable program name-lapue
NOTE: If-lapue is written before the source program, an error occurs, such as. GCC ls1.c-O LS1-lapue [/Code].
Because
. A must be placed after the file during Link
. So when linking, there is no requirement on the location, both the front and back can be
Learning UNIX Advanced Programming
1. Download the source code from www.apuebook.com.
2.tar unpack, CD apue.2e
3. VI make. Defines. Linux: Modify the variable wkdir to point to the location of your apue source code. my options are/home/huangz/code/apue.2e, so
Wkdir =/home/huangz/code/apue.2e
4. VI Include/apue. h adds a constant arg_max, which is used by threadctl/getenv1.c and threadctl/getenv3.c. The value 4096 is provided in reference. If there is any problem, modify it.
# Define arg_max 4096
5. Added VI threadctl/getenv1.c.
# Include "apue. H"
6. Added VI threadctl/getenv3.c.
# Include "apue. H"
7. Modify row 31st by VI threads/badexit2.c and convert the return value of pthread_self () to the int type.
Printf ("thread 2: ID is % d \ n", (INT) pthread_self ());
Http://blog.csdn.net/ce_endless/article/details/6885708
9. Make
10. sudo CP include/apue. h/usr/include
Sudo CP lib/libapue. A/usr/lib
Okay. Test it. Remember to use the-lapue command to connect the compiler to the apue library.
GCC main. C-lapue
Compile and run the program
GCC source program. C-o executable program name-lapue
NOTE: If-lapue is written before the source program, an error occurs, such as. GCC ls1.c-O LS1-lapue [/Code].
Because
. A must be placed after the file during Link
. So when linking, there is no requirement on the location, both the front and back can be