UNIX Environment Advanced Programming CentOS Configuration APUE compilation environment

Source: Internet
Author: User

First make sure that GCC is already installed in the operating system.

Unzip the apue.2e into the Linux operating system and enter

[[Email protected] apue.2e]# CD Lib

Enter the Lib folder of the apue.2e.

[Email protected] lib]# make-f linux.mk

Then find libapue.a from the Apue.2e/lib folder, find apue.h from the Apue.2e/include folder, and copy both to the source directory (the directory where you wrote your. c file), enter

[Email protected] test]# Gcc-o main MAIN.C libapue.a

Compilation succeeded, input

[Email protected] test]#./main/dev

can be run.

Appendix:

Run the program code as follows:

#include"apue.h"#include<dirent.h>intMainintargcChar*argv[]) {DIR*DP; structDirent *Dirp; if(argc!=2) Err_quit ("Usage:ls Directory_name"); if(DP = Opendir (argv[1]))==NULL) Err_sys ("can ' t open%s", argv[1]);  while((Dirp=readdir (DP))! =NULL) printf ("%s\n",dirp->d_name);    Closedir (DP); Exit (0);}

The purpose of this program is to print the names of each file in a directory.

UNIX Environment Advanced Programming CentOS Configuration APUE compilation environment

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.