Experience in compiling and installing software from source code + skills + errors
Source: Internet
Author: User
It is not easy to compile and install Dongdong from the source code. Before using LFS, the source code compilation and installation software has never
If you have succeeded or even encountered an error, you have to give up.
After the baptism of LFS, I finally had a little understanding of source code compilation and installation. Unfortunately, I didn't write down these experiences at the beginning.
But it's not too late to start writing now. :) & #160; write down the problems encountered in compilation and the solutions, and accumulate experience,
Newbie can also learn about the source code installation software and have more chances of success. After all, it can be compiled from the source code package.
^_^
How to install software from the source code package?
The most important thing to install software from the source code package is to carefully read the instructions such as readme install. It will tell you how to successfully install & #160;
The steps for installing software from the source code package are as follows:
Tar jxvf gtk316-2.4.13.tar.bz2& #160; unlock the source code package
Cd gtk +-2.4.13/Go to the source code directory
./Configure & #160;It seems that in some environments,./configure may cause terminal exit.
And use
. ConfigureIt will run normally. If this happens, try again.
. Configure
You can use the configure program to guess the host information and create a makefile to complete make. If./configure is not successful
But if you go to make, it will appear
"Make: *** no targets specified and no makefile found. Stop ." MakeAfter./configure is successfully completed, the program will be officially compiled.
Make install & amp; #160;Use make install to install
Make uninstallSome software can be detached.
,This method may be used for uninstallation. If it is supported, it is usually written in readme (it seems that it is relatively small)
The Configure program has many parameters. You can use./configure
-- HelpView Details, usually in front of the General configure
Parameter description, followed by the description of available parameters of the program.
./Configure
-- Prefix =/usrSpecifies the installation directory. The software compiled and installed from the source code package is usually stored in
/Usr/localLower
Because this is
FHS (filesystem Hierarchy Standard)What is FHS? Let's take a look at this article:
Http://www.pathname.com/fhs/pub/fhs-2.3.html I believe it will give you a better understanding of the Linux system structure and it is worth reading.
Let's talk about a few things related to successful compilation:
/Etc/lD. So. conf & #160; ldconfig & #160; pkg_config_path
First, describe/etc/lD. So. conf: This file records the path of the dynamic link library used during compilation.
By default, the compiler only uses the library files in the/lib and/usr/lib directories.
If you have installed some libraries, for example, when installing GTK +-2.4.13, it will require glib-2.0> = 2.4.0.
-- Prefix =/usr & #160; is not specified, so the glib library is installed in/usr/local, but not in/etc/lD. so. add/usr/local/lib in Conf
This search path causes an error when compiling GTK +-2.4.13.
There are two solutions to this problem: A: When compiling the glib-2.4.x, specify the installation to/usr, so that the library file will be placed in/usr/lib, GTK will not find the required Library File
This is a good method for installing library files, so you do not need to set
Pkg_config_path(Description later)
2. Add/usr/local/lib to/etc/lD. so. conf. Then, when installing GTK, you will search for/usr/local/lib and find the required library.
Adding/usr/local/lib to/etc/lD. So. conf is also required. In this way, the problem will not occur when you install Dongdong to local.
It is wise to add the paths that may store the library files to/etc/lD. So. conf. ^_^ The addition method is extremely simple. It is okay to directly write the absolute path of the library file into it, one line at a time. For example:
/Usr/x11r6/lib /Usr/local/lib /Opt/lib
Let's take a look at what ldconfig is like: It is a program, usually located under/sbin, which is used by the root user. The specific functions and usage can be:
Man ldconfigCheck
Simply put, its role
Cache the library files in the paths listed in/etc/lD. So. conf to/etc/lD. So. cache for use. Therefore, after installing some library files (such as just installed Glib), or modifying lD. So. conf to add a new library path, run/sbin/ldconfig
So that all library files are cached in LD. So. cache. If not,
Even if the library file is clearly under/usr/lib, it will not be used., Result
During the compilation process, I encountered an error and lacked the xxx library. I found that the library was clearly there. I wanted to yell at computer pig. Pai_^
I once made this mistake when compiling KDE (it needs to be run once every compilation of a good stuff), so
Remember to run ldconfig after modifying the library file, and run it in any directory.
Let's talk about the variable pkg_config_path: I often see someone asking on the Forum"
Why does GTK +-2.4.x still prompt that the glib version is too low? Why did I install the glib-2.4.x, or did I prompt that a?... could not be found ?......"It's all about this variable.
First, let's take a look at the errors that occur during the compilation process (compile GTK +-2.4.13 ):
Checking for PKG-config...
/Usr/bin/PKG-config Checking for glib-2.0> = 2.4.0 & #160; & #160; & #160; ATK> = 1.0.1 & #160; & #160; & #160; pango> = 1.4.0...
Package glib-2.0 was not found in the PKG-config search path. Perhaps you shoshould Add the directory containing 'glib-2.0.pc' To the pkg_config_path environment variable No package 'glib-2.0 'Found Configure: Error: library requirements (glib-2.0> =
2.4.0 & #160; & #160; & #160; ATK >=1.0.1 & #160; & #160; & #160; pango >=
1.4.0) not met;
Consider adjusting the pkg_config_path Environment Variable if your libraries are in a nonstandard prefix so PKG-config Can find them. [Root @ newlfs
GTK +-2.4.13] # & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160; & #160;
Obviously, in the above section,
The glib-2.4.x was not found and prompted that the glib-2.0.pc should be added to pkg_config_path. Exactly this
PKG-config pkg_config_path glib-2.0.pcWhat is it? Let me tell you have _^
First, let's talk about how it came out.
Pkgconfig-x.x.xAfter this package, there will be more
PKG-config, It is needed
Pkg_config_pathDongdong
What is pkgconfig-x.x.x? Here is a description:
The pkgconfig package contains
Tools
Passing the include path and/or library paths to build Tools during the make File Execution. PKG-configIs a function that Returns meta information for the specified library.
The default setting for pkg_config_path is
/Usr/lib/pkgconfig because of the prefix
We use to install pkgconfig. You may add to pkg_config_path by exporting additional paths on your
System where pkgconfig files are
Installed. Note that pkg_config_path
Is only Needed when compiling packages, not during Run-Time.
After reading this instruction, you probably know what it is.
In fact, PKG-config is a program that provides system information to the configure program, such
The software version, the Library version, and the library path., Etc.
The information is only in
Use during compilation. You can
Ls/usr/lib/pkgconfigYou will see a lot of *. PC, open it in a text editor
You will find information similar to the following:
See, configure depends on the information to determine whether your software version meets the requirements. And get the location where these things are located, or where to find them.
I don't need to say that you also know why the above problems have occurred.
The solution is simple,
Set the correct pkg_config_pathIf the glib-2.x.x is mounted to/usr/local/, then the glib-2.0.pc will
/Usr/local/lib/pkgconfigTo add the path
Pkg_config_pathNext.
And make sure that configure finds the correct Glib-2.0.pcThat is, the other lib/pkgconfig directory glib-2.0.pc is killed. (If yes, ^-^)
Can be added
~ /. BashrcFor example:
Pkg_config_path =/opt/kde-3.3.0/lib/pkgconfig:/usr/local/pkgconfig: /Usr/x11r6/lib/pkgconfig [Root @ newlfs ~] # Echo $ pkg_config_path
/Opt/kde-3.3.0/lib/pkgconfig:/usr/local/pkgconfig:/usr/x11r6/lib/pkgconfig
As shown above,
When installing the library file, it is very good to specify the installation to/usr, whether it is/etc/lD. So. conf or pkg_config_path By default, the/usr/lib, Can save a lot of trouble, but from the source package management, are installed under/usr
Management is a problem. It is better to install it in/usr/local for convenient management.
In fact, you only need to set lD. So. conf, pkg_config_pathAfter path
,Okay! ^_^
Some other software, such as the emacs-21.3, cannot be compiled successfully under the gcc-3.4.x due to version reasons, (make error) The GCC of earlier versions may be compiled. It may be because of the great changes in gcc-3.3.x and gcc-3.4.x.
If you have thought so much about it for the time being, write it down first. If you have a little understanding of the source code package compilation, you will not waste me writing this word for so long. ^ _ ^ & #160;
In addition, when the./configure is passed and make fails, it is difficult to solve such a problem. You can only find the cause based on experience. For example, a header file is not found,
At this time, you need to find an error along the line at the wrong position, such as display
XXXX. H & #160; no such file or directoryHeader file missing
Then go to Google to search.
Or find the error information that feels valuable and get Google to search for it, you will often find a solution. Let's take a closer look at readme and install
How to install the program, what dependent files are needed, and so on.
In addition, for newbie, it is often not known whether the compilation is successful or not, but if the compilation fails, make install
Errors are inevitable, increasing the complexity of solving the problem. You can check whether the compilation is successful using the following method:
1. After compilation, input echo $? If the returned result is 0, the result ends normally. Otherwise, an error occurs. Echo $? Check the exit status of the previous command. If the program Exits normally, 0 is returned. If the program Exits normally, non-0 is returned.
Ii. during compilation, you can use
&&Connection command,
&&Indicates that "the current command ends normally, and the subsequent command will be executed", that is, "and.
This method is good, that is, saving time and preventing errors. Example:
./Configure -- prefix =/usr & make install
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.