Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Program package

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Installation of compiled source code for package management

Why compile and install the source code?

1. The corresponding package cannot be obtained directly

two。 The compiled binary does not contain the functions we need.

3. The compiled binary contains so many functions that we don't need

1. Wanted to use a package, but could not find an available binary package

two。 The package we want to use has a binary format, and the features or features we need have not been compiled

The source code package for a program is available in two formats:

Original source code package: name-VERSION.tar.gz

The tar xf command releases the source file in the package

Rpm encapsulated source code package: name-VERSION.release.src.rpm

Rpm-ivh installs the source code files to a directory

The organization of the source code package:

Multiple source code files

There may be dependencies between different code segments of the same file or different code snippets of different files.

When compiling source code, some code snippets must be compiled first, or code snippets in a file must be compiled before subsequent compilation

There may be cross-file dependencies between source code files, which are best known only to their authors

Programmers write illustrative documents to make it easier for users to understand the dependencies between files and between code snippets and code snippets.

Later, the programmer will attach a header information to each source code file to explain the dependency between the file and the code snippet. The programmer developed a tool to extract and summarize such information, combined with the configuration last class provided by the programmer. Targeted generation of chapter-by-chapter documentation, including: which preprocessor is called for this compilation? How to carry on the pretreatment? Which compiler is called? Which assembler is called? How to compile it? Under which path does the program need to be installed?

Source code project management tools

CAccord Centrum: make

Java:maven

Python:buildout

Illustrative documents: files such as makefile are not fixed, but are constantly changing according to the user's choice

The makefile file is generated using the template of makefile.in (makefile.win)

Using the configure script, the user's choice is accepted, and the configure script summarizes all the information received into the makefile.in template, replacing the corresponding content in the template, thus generating the makefile file.

Programmers write source code and add header information to source code files; provide template files for Makefile.in

Need autoconf tool to generate configure script

Need the automake tool and use all the parameters accepted by the configure script to create the makefile file

With the correct makefile file, you can use the make command to compile the source code

Preprocessing-- > compile-- > assemble-- > Link-- > generate executable binaries

Install binaries-copy binaries to the correct directory path if you already have a configure script in the source code package during the current source code compilation, we also need to do the following

1. Use the. / configure script to generate makefile files based on the option information provided by the user

2.make

3.make install

Suggestion: it is best to check the install file in the source code package before actually installing the package. If you don't have this file, check the readme file.

How to get the source code package of an open source program

1. Apache.org mariadb.org kernel.org, the official site for publishing the program

two。 Code hosting site

SourceForge

Github.com

Code.google.com

Prerequisites for source code compilation and installation on Linux systems:

1. The compiler development environment must meet the requirements

Centos6 system

Yum groupinstall "Development tolls"server platform development"

Centos7 system

Yum groups install "Development tolls"

two。 The compiler should meet the requirements.

Gcc,cpp,make,automake...

3. The standard library used in compilation should be a complete glibc,c standard library.

After meeting the above conditions, you can then compile and install the source code.

1. Run the configure script

A large number of options: various paths used in the top installation process, startup or shutdown features, etc.

-- help: get all the options supported by the package

Classification of options

Installation path option

-- prefix= path (/ PATH/TO/SOFTWARE_INSTALL)

System Type option

If all system type options are not selected, the default compilation is based on the local default operating system and platform architecture, or other file systems and other platform types can be selected at the time of compilation. this is often called cross-compilation.

Optional property options:

-- disable-FEATURE

-- enable-FEATURE

When compiling source code, choose to enable or disable a feature or feature

Optional package options:

When compiling source code, some features in the source code may depend on other external packages

-- with-PACKAGE

-- without-PACKAGE

Choose to use or not to use external packages

The above commands and options will then automatically create a makefile file in the source code directory

2.make [- j] # (cannot exceed the number of processor cores)

3.make install

After the source code is installed, do the finishing touches

1. Everywhere the directory where the binary program is located is in the PATH variable

In / etc/profile.d/name.sh

Export PATH=/PATH/TO/BINARY:$PATH

Source / etc/profile.d/name.sh

two。 Export the library file:

Edit / etc/ld.so.conf.d/name.conf

/ PATH/TO/SOFTWARE_LIBRARY

Ldconfig [- v]

3. Export the header file:

Create a corresponding symbolic link

Ln-sv / PATH/TO/HEAD_FILE / uer/include/name

4. Export help file

The help file has been exported by default in centos7

Centos6

Edit the / etc/man.config file to add a new line to the file

MANPATH=/PATH/TO/MAN_FILE

Example installation of httpd-2.4.18

1. The first step is to solve the development tools environment.

Yum groupinstall "Development tools"

two。 Use apr and apr-util tools for httpd-2.4.18 versions

Install apr tools

~] # tar xf apr-1.5.2.tar.bz2-C / usr/src

~] # cd / usr/src/apr-1.5.2

~] # / configure-- prefix=/usr/local/apr-1.5.2

~] # make

~] # make install

Install arp-util tools

~] # tar xf apr-util-1.5.4.tar.bz2-C / usr/src

~] # cd / usr/src/apr-util-1.5.4

] # / configure-- prefix=/usr/local/apr-util-1.5.4-- with-apr=/usr/local/apr-1.5.2

~] # make

~] # make install

3. Pcre-devel needs to be installed to meet the regular expression usage requirements of httpd

Yum-y install pcre-devel

Compile and install httpd:

~] # tar xf httpd-2.4.18.tar.gz-C / usr/src

~] # cd / usr/src/httpd-2.4.18

] # / configure-- with-apr=/usr/local/apr-1.5.2-- with-apr-util=/usr/local/apr-util-1.5.4

~] # make

~] # make install

Closing:

1. Export binaries:

Vim / etc/profile.d/httpd.sh

Export PATH=/usr/local/apache2/bin:$PATH

Source / etc/profile.d/httpd.sh

two。 Export the library file:

Vim / etc/ld.so.conf.d/httpd-x86_64.conf

/ usr/local/apache2/modules

Ldconfig-v

3. Export the header file:

Ln-sv / usr/local/apache2/include / usr/include/httpd

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report