Problems encountered during tarball compilation and Solutions

Source: Internet
Author: User
Article Title: problems encountered during tarball compilation and solutions. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
  
  
It is not very easy to compile and install Dongdong from the source code. Before using lfs, the source code compilation and installation software has never been successful, and even errors cannot be solved.
After the baptism of lfs, I finally had some knowledge about source code compilation and installation, it's a pity that I didn't write down these experiences at the beginning, but now I can't write down the problems encountered in compilation and the solutions, so as to accumulate experience, newbie can also learn about source code installation software and have more chances of success. After all, it is good to compile the source code package.
First, let's talk about the basic method of source code compilation, several important files in the source code compilation process, and the setting of the key variable PKG_CONFIG_PATH. It is often seen in the forum that some people fail to compile the source code, which is a ghost of this stuff.
  
   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 install it successfully.
  
The steps for installing software from the source code package are as follows:
  
Tar jxvf gtk0000-2.4.13.tar.bz2 unbind the source code package
Cd gtk +-2.4.13/enter the source code directory,
./Configure seems to be in some environments./configure will cause the terminal to exit.
However, using. configure will run normally. If this happens, try. configure.
You can use the configure program to guess the host information and create a Makefile to complete make. If./configure is not successful
When you go to make, "make: *** No targets specified and no makefile found. Stop ."
Make starts to compile the program after./configure is successfully completed.
After successful compilation, make install is used for installation.
Make uninstall some software supports uninstallation. 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 -- help to view the details.
Parameter description, followed by the description of available parameters of the program.
./Configure -- prefix =/usr specifies the installation directory. The software compiled and installed from the source package is usually stored under/usr/local by default.
Because this is the FHS (Filesystem Hierarchy Standard) rule, do not know what is FHS? Let's take a look at this article:
Http://www.pathname.com/fhs/pub/fhs-2.3.html believes it will give you a better understanding of the linux system structure, it is worth reading.
  
Let's talk about a few things related to successful compilation:/etc/ld. so. conf ldconfig 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 is not specified, so the glib library is installed under/usr/local, and/usr/local/lib is not added to/etc/ld. so. 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 the library file, so you do not need to set PKG_CONFIG_PATH (described 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 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 ldconfig.
  
It is a program, usually located under/sbin, which is used by the root user. The specific functions and usage can be found in man ldconfig.
To put it simply, it caches 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. after adding a new library path to the conf file, run/sbin/ldconfig to cache all the library files to the ld. so. cache, if not done, even if the library file is clearly under/usr/lib, it will not be used. An error is reported during the compilation process, and the xxx library is missing, check and find that it is clearly there.
I have made this mistake when compiling KDE (it needs to be run once every time it is compiled), so remember to run ldconfig after modifying the library file, you can run it in any directory.
  
  
Let's talk about the variable PKG_CONFIG_PATH:
  
I often see someone asking on the Forum, "Why have I installed the glib-2.4.x, But compiling gtk +-2.4.x still prompts 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 atk> = 1.0.1 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 atk> = 1.0.1 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] #
Obviously, the above section shows that no glib-2.4.x is found and prompts that the glib-2.0.pc should be added to PKG_CONFIG_PATH.
What exactly is this pkg-config PKG_CONFIG_PATH glib-2.0.pc doing? Let me tell you have _^
Let's talk about how it came out, when the pkgconfig-x.x.x package is installed, there is more pkg-config, it is the content of PKG_CONFIG_PATH,
What is pkgconfig-x.x.x? Here is a description:
  
The pkgconfig package contains tools for passing the include path and/or library paths to build tools during the make file execution.
Pkg-config is 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 as the software version, library version, library path, and so on.
This information is only used during compilation. You can see a lot of *. pc under ls/usr/lib/pkgconfig and open it in a text editor,
You will find information similar to the following:
  
Prefix =/usr
Exec_prefix =$ {prefix}
Libdir =$ {exec_prefix}/lib
Includedir =$ {prefix}/include
  
Glib_gen1_al = glib-gen1_al
Gobject_query = gobject-query
Glib_mkenums = glib-mkenums
  
Name: GLib
Description: C Utility Library
Version: 2.4.7
Libs:-L ${libdir}-lglib-2.0
Cflags:-I $ {includedir}/glib-2.0-I $ {libdir}/glib-2.0/include
  
Configure determines whether your software version meets the requirements based on the information and obtains the location of these items.
  
  
The solution is very simple, set the correct PKG_CONFIG_PATH, if the glib-2.x.x is installed under/usr/local/, then the glib-2.0.pc will be under/usr/local/lib/pkgconfig, add this path to PKG_CONFIG_PATH. And make sure that configure finds the correct glib-2.0.pc, that is, to remove the other lib/pkgconfig directory glib-2.0.pc.
After setting, you can add it ~ /. Bashrc, for 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
  
It can be seen from the above that it is very good to specify the installation to/usr when installing the library file, whether it is/etc/ld. so. conf or PKG_CONFIG_PATH will search for/usr/lib by default, which saves a lot of trouble. However, from the source package management perspective, it is a problem to manage all packages under/usr, it is better to install it in/usr/local to facilitate management. In fact, you only need to set the ld. so. conf, PKG_CONFIG_PATH.
  
Some software, such as the emacs-21.3, cannot be compiled successfully under the gcc-3.4.x due to version reasons, (make error), using a lower version of gcc may be compiled through.
It may be because of the great changes in gcc-3.3.x and gcc-3.4.x.
  
In addition. /configure passed, make error, it is difficult to solve this 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 location, for example, xxxx is displayed. h no such file or directory indicates that the header file is missing and then google searches.
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 how the README, INSTALL program is installed, what dependent files are needed, and so on.
  
In addition, newbie often does not know whether the compilation is successful or not. If the compilation fails, make install will inevitably cause errors, increasing the complexity of solving the problem, you can use the following method to check whether
Related Article

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.