Ubuntu Linux how to use the source files to install software

  

Ubuntu comes with a wealth of software, these software is generally easy to install using graphical automatic ("Add /Remove" or "Synaptic"), but For new software that has just come out, Ubuntu's source has not been included, then we need to use a more general installation: manually install the software from the source files. The detailed steps of this manual installation are described below.


First, install the compiler


Because the source code is compiled, the first step is to install programs such as compile and build. If you have already installed it, you can skip this step. In the Ubuntu system is very simple, just execute the following command:


$ sudo apt-get install build-essential


After the command is executed, install from the source file The tools required for the software, such as gcc, make, g++, and other required software are installed.


Second, download and compile the source code of the software


When we download the source file, we must find out the library files and other programs that the software depends on, and First install them. This information can usually be found on the home page of the open source project. After doing all the preparations, we can do the following work. Because the source code of the software is usually released as a compressed file, you need to extract it to the specified directory. The command is as follows:


OwnLinux@ubuntu:~$ tar xvzf

program.tar.gz

OwnLinux@ubuntu:~$ cd

program/


If you are not familiar with the tar command, please click here to read the "tar command detailed"


When installing the program from the source file under Linux, there is A common mode, configuration (./configure) –> make –> install (sudo make install). However, before you read the installation instructions included in the source file, the developer's instructions are the most authoritative for each program. Program developers usually store installation instructions in a file called INSTALL or README. Where can I find these documents? They can be found on the project home page or in the source code home directory.


1. Configuration


The first step in building an application is to execute the configure script, which is located in the main directory of the program source file:

< BR>OwnLinux@ubuntu:~/program$ ./configure


The script will scan the system to ensure that all the library files required by the program already exist, and make the file path and other required Set up the work. If the library file required by the program is not complete, the configuration script will exit and tell you which library files are needed or which versions are too old to be updated. If this is the case, it is not enough to get the package containing the library file. Also, find the development package that has all the header files of the library file. In Ubuntu, such a package generally uses -dev as the file name. The end. After installing all the required library files, re-run the configuration script until there is no error message, which means that the required library files have been installed properly and the dependencies are satisfied.


2. Compile


When the configuration script exits successfully, the next thing to do is to compile the code. The specific operation is to run the make command in the home directory of the source file:


OwnLinux@ubuntu:~/program$ make


At this point, you will see a string Compile the output data and quickly scroll through the screen. If it is normal, the system will return the prompt status. However, if an error occurs during compilation, the troubleshooting process is not as simple as the configuration steps. Because this usually involves debugging the source code, maybe the source code has syntax errors, or other errors. How to do? If you are a programming expert, debug it yourself! Otherwise, check the software's mailing list and other support channels to see if it is a known bug. If it is to see how others solve it, don't submit a bug report, maybe there will be a solution soon.


3. Installation


When the software is successfully compiled, the final step is to install them on the system. Most of the program's makefiles will have a function for installation. It should be noted that most of the time we have to install the program as the root user, so the program installs the file into /usr or other directories where only the superuser has write access. Still in the main directory of the source file, execute the following command:


OwnLinux@ubuntu:~/program$ sudo make install


Oh, so the program will Installed on your computer. In addition, when you no longer use the program, you can use the uninstall function that comes with the software, which is available in general programs. Switch to the home directory of the source file and execute the following command:


OwnLinux@ubuntu:~/program$ sudo make uninstall


In most cases, use the above The installed methods of the methods are located under /usr/local. If you want to install the installed program files from the Ubuntu patrol file system, you can add items to the command as follows:


OwnLinux@ubuntu:~/program$ ./configure –prefix= /opt


Although this is generally effective, there are exceptions. Some programs simply ignore items; some programs, such as programs that contain kernel modules, put all of them into your file. system.


The method of manually installing the software described above is introduced for the Ubuntu environment, but the methods for installing applications from source files under various Linux systems are basically the same.

Copyright © Windows knowledge All Rights Reserved