Compiling and installing source code in Linux

Source: Internet
Author: User

Compiling and installation in LinuxSource codeThere are three steps:./configure, make, make install

Step 1CodeDirectory

Run commands

 
1./Configure -- prefix = installation directory -- target = Target Platform

The above two are the most basic, some source code installation requires dozens of parameters, specific can only refer to the specific description.

./Configure common Parameter Parsing, from http://blog.csdn.net/caijp1090/article/details/7422460

The 'configure 'script has a large number of command line options. For different software packages, these options may change, but many basic options will not change. Run the '-- help' script to view all available options. Although many options are rarely used, it is helpful to know their existence when you configure a package for special needs. Next we will give a brief introduction to each option:

-- Cache-file = File

'Configure 'tests existing features (or bugs!) on your system !). To accelerate subsequent configuration, the test results are stored in a cache file. When configure has a complex source code tree with 'configure 'scripts in each subtree, the existence of a good cache file will be of great help.

-- Help

Output help information. Even experienced users occasionally need to use the '-- help' option, because a complex project contains additional options. For example, the 'configure 'script in the GCC contains options that allow you to control whether to generate and use the GNU Compiler in GCC.

-- No-create

A major function in 'configure 'creates an output file. This option prevents 'configure 'from generating this file. You can think of it as a dry run, although the cache is still rewritten.

-- Quiet

-- Silent

When 'configure' performs his/her test, a brief message is output to tell the user what is being done. In this way
Because 'configure 'may be slow, and without such output, the user will be thrown aside to wonder what is going on. using either of the two options will throw you aside. Note:
These two statements are interesting. The original Article is as follows: if there was no such output, the user wocould be left
Wondering what is happening. By using this option,
You too can be left wondering !)

-- Version

Print the Autoconf version used to generate the 'configure 'script.

-- Prefix = pewfix

'-- Prefix' is the most common option. The generated 'makefile' will view the parameters passed with this option
When a package is installed, its structural independence can be completely relocated. For example, when installing a package, such as Emacs, the following command will make Emacs LISP
File is installed to "/opt/GNU/share ":

$./Configure -- prefix =/opt/gnu

-- Exec-Prefix = eprefix

It is similar to the '-- prefix' option, but it is used to set the installation location of the file relying on the structure. The compiled 'memacs' binary file is such a question. If this option is not set, the default option value is set to the same as the '-- prefix' option value.

-- Bindir = dir

Specifies the installation location of the binary file. The binary file here is defined as a binary file that can be directly executed by the user.Program.

-- Sbindir = dir

Specifies the installation location of the Super binary file. This is a program that can only be executed by Super Users.

-- Libexecdir = dir

Specifies the installation location of executable support files. In contrast to binary files, these files are never directly executed by users, but can be executed by the binary files mentioned above.

-- Datadir = dir

Specifies the installation location of common data files.

-- Sysconfdir = dir

Specifies the installation location of read-only data used on a single machine.

-- Sharedstatedir = dir

Specifies the installation location of writable data that can be shared on multiple machines.

-- Localstatedir = dir

Specifies the installation location of writable data that can only be used by a single machine.

-- Libdir = dir

Specifies the installation location of the library file.

-- Includedir = dir

Specifies the installation location of the C header file. You can also use this option for header files in other languages such as C ++.

-- Oldincludedir = dir

Specify the installation location of the C header file installed by the compiler except GCC.

-- Infodir = dir

Specifies the installation location of the Info format document. info is the document format used by the GNU project.

-- Mandir = dir

Specifies the installation location of the manual page.

-- Srcdir = dir

This option does not work for installation. It will tell the 'configure 'source code location. Generally, you do not need to specify this option, because the 'configure 'script is generally in the same directory as the source code file.

-- Program-Prefix = prefix

Specifies the prefix that will be added to the name of the installed program. For example, use '-- Program-
Prefix = G' to configure a program named 'tar ', which will name the installed program 'gtar '. This option is only available when it is used together with other installation options.
It works only when used by the 'makefile. in' file.

-- Program-suffix = suffix

Specifies the suffix that will be added to the name of the installed program.

-- Program-transform-name = Program

The program here is a sed script. When a program is installed, its name will pass through 'sed-e program 'to generate the installation name.

-- Build = build

The system platform where the software package is installed. If not specified, the default value is the value of the '-- host' option.

-- Host = Host

System platform where the software runs. If not specified. Run 'config. Guess 'to detect the vulnerability.

-- Target = garget

Specifies the target to system platform of the software. This mainly plays a role in programming language tools such as compiler and assembler context. If not specified, the '-- host' option value is used by default.

-- Disable-feature

Some software packages can choose this option to provide compilation configuration for large options, such as using the Kerberos authentication system or an experimental compiler optimal configuration. If these features are provided by default, you can use '-- disable-feature' to disable them. Here 'feature 'is the name of the feature, for example:

$./Configure -- disable-Gui

-Enable-feature [= Arg]

On the contrary, some software packages may provide some features that are disabled by default. You can use '-- enable-feature' to start using it. Here, 'feature 'is the feature name. A feature may accept an optional parameter. For example:

$./Configure -- enable-Buffers = 128

'-- Enable-feature = no' is synonymous with' -- disable-feature 'mentioned above.

-- With-package [= Arg]

In Free SoftwareCommunityThere is an excellent tradition of using existing software packages and libraries. When 'configure 'is used for configuration
When setting up a source code tree, you can provide information about other installed software packages. For example, the BLT device toolkit relies on Tcl and TK. To configure BLT, you may need to provide 'configure'
For some information about where we installed tcl and TK:

$./Configure -- With-tcl =/usr/local -- With-TK =/usr/local

'-- With-package = no' is synonymous with' -- without-package 'mentioned below.

-- Without-Package

Sometimes you may not want your software package to interact with the existing software package of the system. For example, you may not want your new compiler to use GNU lD. You can do this by using this option:

$./Configure -- without-GNU-LD

-- X-regiondes = dir

This option is a special case of the '-- With-package' option. Initially in Autoconf
When it is developed, 'configure 'is widely used as a work und for imake to create software running on X. The '-- X-include' option provides
The 'configure 'script specifies the directory containing the X11 header file.

-- X-libraries = dir

Similarly, the '-- X-libraries' option provides a method for specifying the directory containing the X11 Library to the 'configure' script.

 

 

Use of make

Generally, you only need to use make directly. However, sometimes the C compiler or C ++ compiler is not specified in the generated makefile, otherwise, a compilation error may occur.

Make cc = specifies the C language compiler

Make cxx = specifies the C ++ Compiler

 

The last step is simple.

Use make install.

 

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.