25. File System--compilation and installation of source program (Make,make install,ldd,ldconfig-v)

Source: Internet
Author: User
Tags coding standards automake

I. Overview of the source file structure

The GNU organization provides source code for users to compile and use themselves. For example, the famous Apache Web Server is a typical source file:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5B/38/wKiom1UCBCrB1vyYAAjB6_s8ZJA143.jpg "title=" 123. PNG "alt=" wkiom1ucbcrb1vyyaajb6_s8zja143.jpg "/>

We can download this source code and upload it to the Linux machine via firezillar on the Windows Platform:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/5B/32/wKioL1UCBWKTGTOAAAYnLUieYH8410.jpg "title=" 124. PNG "alt=" wkiol1ucbwktgtoaaaynluieyh8410.jpg "/>

[Email protected] ~]# cd/yum/bin_src/

[email protected] bin_src]# LL

Total 4940-rw-r--r--. 1 root root 5054838 17:51 httpd-2.4.12.tar.bz2


If the package is not uploaded by ftp tools such as FileZilla , but is downloaded directly from the server, in order to ensure that the local package can match the package time on the server, it is recommended to use ntpdate server_ip to adjust local time to server time

[[Email protected] bin_src]# Date

Sun 17:57:25 EDT 2014

[Email protected] bin_src]# ntpdate 192.168.56.103

18:00:32 ntpdate[24526]: No server suitable for synchronization found# because the Local has not built the server, it can not be synchronized, the article will introduce the server building


[Email protected] bin_src]# Tar XF httpd-2.4.12.tar.bz2

# Expand the Zip package

[[email protected] bin_src]# ls

httpd-2.4.12 httpd-2.4.12.tar.bz2

[Email protected] bin_src]# CD httpd-2.4.12

[[email protected] httpd-2.4.12]# ls server/

BUILDMARK.C gen_test_char.dsp provider.c util_expr_parse.c util_pcre.cconfig.c listen.c request.c util_expr_parse.h util_regex.c...error_bucket.c nwgnumakefile util_ebcdic.c util_md5.cgen_ TEST_CHAR.C protocol.c util_expr_eval.c util_mutex.c


[Email protected] httpd-2.4.12]# CD server/

[email protected] server]# cat BUILDMARK.C

# you can see the contents of the file ending in. c, which is the C language source code/* Licensed to the Apache software Foundation (ASF) under one or more * Contributor license agree  ments. See the NOTICE file distributed with ... * limitations under the License. */#include "ap_config.h" #include "httpd.h" #if defined (__date__) && defined (__time__) static const char Server_ built[] = __date__ "" __TIME__; #elsestatic const char server_built[] = "Unknown"; #endif ap_declare (const char *) ap_get_s Erver_built () {return server_built;}

Two . installation steps for software packages

Serverthe directory has*.cThe file is the source program because the package group was previously installedDevelopment Tools,Server Platform Developmentand theDesktop Platform Development, so users can useGCCto compile these files. However, to successfully install the compilation of a source program, it is not easy to usegcc *.c, as these*.cfiles have dependencies on each other, have a certain compilation order, and if they do not follow the order, an error occurs. To simplify the operation, there was a MakeTools:

[[email protected] server]# which make

/usr/bin/make[[email protected] server]# man Makemake (1) LOCAL USER COMMANDS MA KE (1) NAME make-gnu make utility to maintain groups of programs--# makes can manage a set of files, that is, manage a project synopsis make [-F Makefile] [options] ... [Targets] ...


 make The appearance of make makefile makefile Specify a specific compilation method, such as the Order of compilation, the optimization of compilation and so on. This file is often difficult to write manually, but instead uses a script configure makefile.in to generate makefile file:

about_apache     buildall.dsp    configure.in   installbin.dsp  notice             serveracinclude.m4     buildbin.dsp    docs           LAYOUT           nwgnumakefile     srclibapache-apr2.dsw  buildconf        emacs-style   libhttpd.dsp    os                 supportApache.dsw        CHANGES         httpd.dsp      LICENSE         README           &nbsP; testapache_probes.d  cmakelists.txt  httpd.spec    makefile.in      READMENaNake      VERSIONINGap.d              config.layout   include        Makefile.win    README.platformsbuild             configure        install       modules          Roadmap

Usually configure This script is also difficult to generate manually, but the software package authors use the autoconf tool, combined with the various parameters of the package to automatically generate:

[Email protected] httpd-2.4.12]# Rpm-qi autoconf

Name:autoconf Relocations: (Not relocatable) ... Description:gnu Autoconf is a tool for configuring source code and Makefiles.using Autoconf, programmers can create Porta Ble and configurablepackages, since the person building the package is allowed tospecify various configuration options.# C Onfigure files are usually made of packages

Configure scripts need to combine makefile.in to generate Makefile files, and makefile.in The files are generated using the Automake tool:

[Email protected] httpd-2.4.12]# Rpm-qi Automake

Name:automake Relocations: (Not relocatable) ... Summary:a GNU tool for automatically creating Makefilesdescription:automake are A tool for automatically generating ' Makefile.in ' files compliant with the GNU Coding standards.

In summary, the process of compiling and installing a package is as follows:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/5B/38/wKiom1UCBFmyDudfAAF12lOOpvk089.jpg "title=" 125. PNG "alt=" wkiom1ucbfmydudfaaf12loopvk089.jpg "/>

Maybe we'll have a question, since make final use of the Makefile file, then why not write the configuration directly to Makefile , and superfluous production What about the Configure file? This is because ./configure has the following effects:

1) Check the compilation environment is complete; 2) Let the user customize the compilation configuration (through scripting options, such as using --help to view)

[Email protected] httpd-2.4.12]#/configure--help

' Configure '  configures this package to adapt to many kinds of  systems. Usage: ./configure [OPTION]... [VAR=VALUE]... To assign  environment variables  (E.g., cc, cflags ...),  specify them asvar=value.   See below for descriptions of some of the useful  variables. defaults for the options are specified in brackets.  configuration:  -h, --help               display this help and exit      --help= Short        display options specific to this  package      --help=recursive    display the  short help of all the included packages  -v, --version            display version information and exit installation directories: #  The following options are most common options   --prefix=prefix         install  architecture-independent files in PREFIX                           [/ usr/local/apache2]#  prefix, specify the installation path, and later if you want to remove the program, you can also specify the path   --sysconfdir=DIR         read-only single-machine data [PREFIX/etc] #  Specify the directory for the Conf file, If not specified, it is automatically created as/usr/local/apache2/conf  --mandir=dir             man documentation [DATAROOTDIR/man]#  Specifies the man directory, if not specified, is automatically created as/usr/local/ Apache2/man  --exec-prefix=eprefix   install architecture-dependent files in eprefix                            [PREFIX]  ... --with-suexec-gidmin     Minimal allowed gid  --with-suexec-logfile   set the logfile &NBSP, ..... Report bugs to the package provider.


This article is from the "Big sword without front of the great Qiao Not Work" blog, please make sure to keep this source http://wuyelan.blog.51cto.com/6118147/1619942

25. File System--compilation and installation of source program (Make,make install,ldd,ldconfig-v)

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.