How to configure apue in Linux

Source: Internet
Author: User
Tags unpack

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

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.