Everyone will download the source code of the program sooner or later, and then try to compile it. If you are a loyal follower of RedHat or Debian, you will eventually find that a program is neither too old nor too new, and you are looking for compiled binary code. The bad one is that the Code may never be correctly compiled whatever you do. Most Linux programs are only beta versions at most. The good one is that the number of programs with no problems in compilation has increased over the past five years, and even if you are not a programmer, you can "fix" those that cannot compile the code correctly.
After downloading, there should be a certain type of compressed package on your hard disk. First, you must extract it (uncompress) and untar it to a directory. In practice, many people put them in this directory:/usr/src. In this way, all things can be put in one place, and you can clear them later. To use this directory, you must have the root identity. If a file packaged with tar is compressed with gzip, the Linux tar program can decompress it and decompress the package at the same time. If your file name is filename.tar.gz, you can go to the/usr/src directory and type:
Tar-xzvf/{path to file}/export filename.tar.gz} [Enter]
This will decompress the file and unpack it. Here is a simple explanation of several parameters: x-Unpack the file z-decompress the file v-display the processing process f-followed by the package file name to be processed. If you use netscape to download the file, you may see an error. Sometimes netscape will decompress the file for you.
Therefore, if you untar it like above, you may see the following information:
Gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error exit delayed from previous errors
Try to execute the preceding command, but delete the z parameter, as shown in the following code: tar-xvf/{path to file}/{filename.tar.gz} [Enter]. The z parameter does not work for such files. The easiest way to unlock this file is the bunzip2 the-program.tar.bz2. In this example, the the-program.tar file is unwrapped by the following command:
Tar-xvf/{path to file}/export filename.tar.gz} [Enter]
After unpacking:
Cd to the directory created when the package was just removed. Use ls to check the files in this directory. First, read the README and INSTALL files. If you have not read these files, do not get help from others. This is why RTFM is widely used online (RTFM is short for 'read The Fucking Manual. The README and INSTALL files will show you how to compile and INSTALL this program.
Compile it and run the "make" command. To enable "make" to start compilation, you must have a file named Makefile. You can also write the make parameter on the command line, but it is not within the scope of this article) there are usually three methods to start Compilation: simple, Imake, and configure.
Simple Compilation:
If you see a file named Makefile -- no file named Imake or configure, you can use this method to compile the file. Because it cannot be set for your computer, there are many problems with this method. The README and INSTALL files usually tell you how to edit some files so that they can be compiled normally. Generally, you can do this:
Make [Enter] make install [Enter]
If everything works, you can run the program now.
Imake: If the ls directory shows the Imake file and there is no Makefile, you can use this method. This is an old method for compiling. Basically, you need to enter:
Xmkmf [Enter] make [Enter] make install [Enter] Configure:
If the directory contains a file named configure, use this method. This is the easiest way to compile a program, and the compilation success rate is very high. Essentially, it will check your system to view every possible crying and supporting file to ensure that you can compile this program and then create Makefile based on the correct information. Run the following command:
./Configure [Enter] make [Enter] make install [Enter]
Note the./before the first command ./. When you type a command, shell will find the file in your path. It does not start from the current directory, So If./(representing the current directory) is not in the path, although ls can see this file, but shell cannot find it. Shell can execute make because it is usually in/usr/bin, while/usr. bin is in the path. To view the path, run the following command:
Echo $ PATH [Enter]
If an error occurs:
The most common error that cannot be compiled is that the file cannot be found. Almost all programs rely on the support of some programs, files or libraries. If they cannot be found, the program cannot be compiled. The README/INSTALL file should tell the files required for compiling the program, and the versions of these files. Note: the wrong version will make it impossible for you to compile just as it does not have this file. Generally, you need to know whether this problem is caused by the error message at the end of the Compilation Program output. This information will tell you what files cannot be found. Note: Sometimes you have these files, but they are not specified in the Makefile file. Use the linux release installer, such as rpm, to check whether some files are lost. If these files are not available, check the Makefile file to see where the file is required. For example, the moc file is in/usr/local/bin, but the Makefile says: moc =/opt/bin/moc. Edit Makefile (using vi or any text editor) and change the moc path.
Another common error is the loss of the "include" file. The first few lines of the original file in many programs are as follows:
# Include
These "h" files (or header files) must exist on your computer. At least you should have the kernel header file, which can be viewed using ls/usr/include/linux. If you have installed some libraries, such as gtk, are you sure you have installed their development files. Sometimes several versions of the same library may cause some problems. Each version may place its header file in different places, but you do not know which file is used during compilation.
If you change all the places in Makefile that should be changed, and all the libraries and header files are correct, and it still cannot be compiled, the sequence is as follows:
1,If you download this program from another site different from the main site of this program, go to its main site to see if there are any updated versions available.
2,Go to dejanews.com and search for this program. It is very likely that other people have encountered the same problem and have posted a solution.
3,If none of the methods work, email the author. Many authors are interested in improving their programs, bug reports, and performance recommendations, and are generally well accepted (Note: This is linux, not commercial software .) Note: It is best to say more about the key situations in your bug report. Do not just say "This program cannot be compiled "! I usually email the last 10 or more lines of the compilation result in the past, so that the author can see the error. If I really like this program, I will try to give the author swimming feedback after the next version is released. Note: programmers are also people-they will have two weeks of vacation, Job hopping, moving, and so on, so don't expect immediate response. Finally, some programs have unique compilation settings: qt and the kernel can be thought of right away. I will repeat it again: Read the README and INSTALL files.
Related Articles]
- Go to the Linux system master path kernel compilation process analysis
- Solution for Makefile not found during Ubuntu Compilation
- Linux kernel modules supporting NTFS Compilation