Problems with installing the source package in Linux

Source: Internet
Author: User
Some problems with installing the source code package in Linux-general Linux technology-Linux technology and application information. The following is a detailed description. This is what Sharkbait found on the Internet. Although it is an example, it is very useful.

Problems encountered during glic installation:
Configure: error: Library requirements (sigc ++-1.2> = 1.1.8 glib-2.0> = 2.0.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.
This article is well written.

Summary
Method 1:
Set./configure -- prefix =/usr
Method 2:
Add/usr/local/lib to/etc/ld. so. conf.
Run/sbin/ldconfig
Method 3:
Export PKG_CONFIG_PATH =/usr/local/lib/pkgconfig?

I think we should develop the habit of the first method.

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
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 terminal exit
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.
Use make install to install
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 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 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. conf to add a new library path, run/sbin/ldconfig
Make all the library files cached in ld. so. cache. If it is not done, it will not be used even if the library file is clearly under/usr/lib.
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 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 _^
First talk about where it came out, when the installation of the pkgconfig-x.x.x package, it is more pkg-config, it is the need for PKG_CONFIG_PATH stuff
What is pkgconfig-x.x.x? Here is a description:

Code:

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

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_PATH, if the glib-2.x.x is mounted to/usr/local/, then the glib-2.0.pc will
Under/usr/local/lib/pkgconfig, add this path to PKG_CONFIG_PATH. And make sure that configure finds the correct
Glib-2.0.pc, is to take the other lib/pkgconfig directory glib-2.0.pc is killed. (If yes, ^-^)
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
By default,/usr/lib is searched, which saves a lot of trouble. However, in terms of source code package management
Management is a problem. It is better to install it in/usr/local for convenient management.
In fact, after you set the ld. so. conf and PKG_CONFIG_PATH paths, it will be OK. ^_^

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. Pai_^

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 location where the error occurs. For example, if xxxx. h no such file or directory is displayed, the header file is 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.
2. During compilation, you can use the & connection command, & to indicate 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

"Cdrom. h: 20: 23: SDL_sound.h: No such file or directory" appears during DOSBOX compilation"

Today, I suddenly wanted to review the Typical DOS game, so I compiled this DOSBOX simulator. In README, I described the need for SDL_SOUND.
So the download and installation went smoothly without specifying the installation path. Therefore, the default installation path is/usr/local/
When compiling DOSBOX make, the following error occurs:
If g ++-DHAVE_CONFIG_H-I. -I. -I .. /.. -I .. /.. /include-I/usr/include/SDL-D_REENTRANT-march = pentium4-O3-pipe-fomit-frame-pointer-MT dos_programs.o-MD-MP-MF ". deps/dos_programs.Tpo "-c-o dos_programs.o dos_programs.cpp ;\
Then mv-f ". deps/dos_programs.Tpo" ". deps/dos_programs.Po"; else rm-f ". deps/dos_programs.Tpo"; exit 1; fi
In file encoded ded from dos_programs.cpp: 30:
Cdrom. h: 20: 23: SDL_sound.h: No such file or directory <------ the cause of the error is here
In file encoded ded from dos_programs.cpp: 30:
Cdrom. h: 137: error: iso c ++ forbids declaration of 'sound _ sample' with no type
Cdrom. h: 137: error: expected '; 'before' *' token
Make [3]: *** [dos_programs.o] Error 1
Make [3]: Leaving directory '/root/software/dosbox-0.63/src/dos'
Make [2]: *** [all-recursive] Error 1
Make [2]: Leaving directory '/root/software/dosbox-0.63/src'
Make [1]: *** [all-recursive] Error 1
Make [1]: Leaving directory '/root/software/dosbox-0.63'
Make: *** [all] Error 2
[Root @ NEWLFS dosbox-0.63] #
It seems that the header file "SDL_sound.h" is not found in cdrom. h.
So the following error occurs, but I have installed SDL_sound?
After searching, SDL_sound.h is found under/usr/local/include/SDL /.
It seems that dosbox does not search for the header file under/usr/local/include/SDL. It is easy to solve the problem after finding the cause.

[Root @ NEWLFS dosbox-0.63] # ln-s/usr/local/include/SDL/SDL_sound.h/usr/include

Link to/usr/include, so that the DOSBOX can be found and compiled successfully.
Once compiled Xorg-6.8.1, also appeared to be unable to find freetype. h problem, the reason is also so.
When compiling and installing software, you may encounter similar situations because you cannot find the required header file.
No relevant header file is installed or is installed but not found, as shown in the preceding example.
If you cannot find it, make a link to/usr/include.
Not Installed: go to google to find something including this header file, and install it.
Generally, the error message is "No such file or directory", so you should look for the error message when compilation fails.
The Error message is always not far from the Error. Be patient. ^_^

Do not modify/etc/ld. so. conf to use the library file in a non-default path ----- LD_LIBRARY_PATH

The environment variable LD_LIBRARY_PATH lists the paths except the default path when searching for shared libraries.
If you do not want to modify or cannot modify (without root permission)/etc/ld. so. conf, use the library files in other paths
You need to set LD_LIBRARY_PATH, for example, export LD_LIBRARY_PATH = $ LD_LIBRARY_PATH:/opt/lib
In this way, you can use the library files under/opt/lib. Of course, it is convenient to modify/etc/ld. so. conf.
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.