Introduction to Source code (there is likely to be cross-file dependencies between the code in the file)
source code (also known as the source program) refers to anCompileIn accordance with a certainProgramming languagesa text file that is written in specification is a series of human-readable computer language instructions. In modern programming languages, the source code can be either a book or aTapeform, but the most common format isText file, the purpose of this typical format is to compile theComputer programs. The ultimate goal of the computer source code is to translate human-readable text into a computer that can performBinary directives, this process is called compiling, byCompilercompleted.
Second, the source code of the compilation process
because the program source code to the computer can be recognized and run instructions are more steps to deal with: The program source code----------------------
Here, take c,c++ as an example to illustrate. After writing the c,c++ source code, the programmer needs to preprocess the source code, that is, the source code is separated or processed by the preprocessor into a specific symbol to support the macro call. After preprocessing, the compiler (GCC) is further compiled into object code, which consists of code that is close to the machine language. The target code is compiled by the compiler to generate machine code, machine instructions that can be recognized by the CPU. Since c,c++ has called library files extensively in writing, it is necessary to link the libraries used in the source code after compiling. The formation can rely on shared libraries to run code independently.
A binary application of a Linux package typically contains (binaries, library files, configuration files, Help files). And the components of a binary application in Linux are:
Binaries:/bin,/sbin,/usr/bin,/usr/sbin,/usr/local/bin,/usr/local/sbin
Library files:/lib,/lib64,/usr/lib,/usr/lib64,/usr/local/lib,/usr/local/lib64
Configuration files:/etc,/etc/directory,/usr/local/etc
Help files:/usr/share/man,/usr/share/doc,/usr/local/share/man,/usr/local/share/doc
three , package compilation and installation Requirements
However, the following procedure is required to turn the source code into an executable binary: program source code--preprocessing---compile----and link. The thought of here we again involuntarily rushed to collapse. And because programs are generally developed using modules in development, there is a good chance that there are cross-file dependencies between the code in the file. Therefore, in order to facilitate users to self-compile source code. So there's the project manager (make).
Four , compiling and installing three steps
C, C + +: Make (Configure--makefile.in--Makefile)
C Code compilation installation three steps:
Premise: Provide development tools and development environment
Development tools: Make, GCC, etc.
Development environment: Development Library, header file
GLIBC: Standard Library
Centos 5,6,7 provides development components through "package groups"
CentOS 6: "Development Tools", "Server Platform development",
①,./configure:
(1) Pass the parameter through the option, specify enable feature, install path, etc., refer to User's designation and makefile.in file generation makefile when executing;
(2) Check the external environment that depends on, if the external environment is not configured at this time, it will cause an error. An error in the first step causes the make to not execute
Options: Specify the installation location, specify the enabled features --help: get the options they support using Options category: installation path setting: --prefix=/PATH/TO/SOMEWHERE: Specify the default installation location; default is/usr/local/ --sysconfdir=/path/to/somewhere: Configuration file Installation Location; System types: Optional Features: Optional features -disable-FEATURE --enable-FEATURE[=ARG] Optional Packages: Optional Packages --with-package[=arg] -- Without-package
②, make:
Build the application according to the makefile file;
③, make install
Copy binary files, library files, configuration files, Help files to the corresponding directory
Precautions:
Configure and Makefile.in are programmers generated by two tools and provided to us using the
Development tools:
AUTOCONF: Generate Configure Script
Automake: Generate makefile.in
Recommendation: View Install,readme before installation
Source code acquisition of open source program:
Official self-built site:
Apache.org (ASF)
mariadb.org
...
Code hosting:
SourceForge
Github.com
Code.google.com
This article is from the "Shutdow-h Now" blog, so be sure to keep this source http://kgdbfmwfn.blog.51cto.com/5062471/1690632
Linux Package compilation Installation