tagline: From openSUSE
|This procedure was tested on openSUSE 12.1|
There can be problems when you compile a program. The new compiled software may replace an old perfectly fitting one or even worse it is possible to compile a virus or a trojan horse.
Thus it is better to first look and see if the application you want is already available as an rpm binary (pre-compiled, the most common rpm) in one of the package repositories. You can also look for a working rpm here, here or here or with a search engine. Another option is to look for alternative programs that have the same functionality. One final option is that for simple applications, it's not always mandatory to have "a SUSE rpm", there is a great chance than any rpm will work (rpm for any usual distribution).
It is extremely unlikely that you would find such malicious code, and it would almost certainly come from a disreputable side of the Internet. Even so, it's best not to be too confident. Such a situation is very rare with Linux, but in the near future there could be a larger risk of problems. With this caution made, remember to not be paranoid either. There is great software available only by compiling so if all else fails, you can compile your own software. Compiling is nothing more than changing the source code into a program that you can run.
First you need to install the development tools. In YaST, go to Software Management, then filter on Selections. Choose at least C/C++ Compiler and Tools. You might also need KDE, Gnome and Tcl/Tk Development and in some cases Kernel Development. The only drawback of installing all this together is a loss of disk space.
Finally, run YaST Online Update to ensure everything is up to date.
If you want to make a local rpm for easy installation and de-installation, then install "checkinstall" as well. (The use of checkinstall is for local machines only and should not be used for programs you intend to distribute.) This is covered by the Alternate Installation section.
Many applications need to have "headers" installed to be compiled. Headers are the part of a programs sources that say what is in the program and where (in the computer language). These headers are often included in "devel" packages. So if a message says "You have not program_name" and you know it's already installed, it's probably because you haven't installed the "devel" part of it. Most "devel" rpms have a name ending with -devel. There is even an option in Yast to install all the devel packages, but this may use a lot of disk space. This is only useful for compiling.
You are ready to go, as the above only needs to be done once. Download the source files. Most of the time they end in tgz, tar.gz or tar.bz2.
Next you must unpack the sources. If the sources have one of the extensions mentioned above, you can unpack them with tar xf filename.tar.bz2 command. If you use KDE, click on the archive in Dolphin and it will open and show you a folder name. Copy/Paste this folder where advisable, or you can simply right click on the package and select Extract. These are your sources :-). A great tool for unpacking is eXtract Everything!.
Move into the directory that you have just created and read the README and/or INSTALL files that are there. If the program has an atypical method for compiling, then it should be explained here. This is very unlikely and the these files will probably describe the following procedure:
You need to verify if all the necessary stuff to compile your application is available. The necessary utility to do so is "configure". So you have to run ./configure. Don't forget the dot slash. You must fix any problem shown by any eventual error message before being able to go further. If the program doesn't have a configure utility, then the reason is probably in the README.
Next you run make. This will build the program and when it is done you already might be able to run it. If you have more than one logical core, you can add the suffix -jX where X is the number of cores you want to use for compilation (this will speed up the process). Look where it is and you can already try it with ./program-name or src/program-name or wherever it is placed inside the directory. Compiling can be very fast or very long depending of the size of the application.
This is normally the only part where you need to be root. This is also a part where the above caution comes into play. Proceed by running su -c make install (su is where you become root, only for this operation). It will ask for your root password and will most likely install the software in /usr/local/bin/.
Another way is to first make an RPM that you can install and de-install. Instead of su -c make install, use su -c checkinstall. This will make an RPM placed in /usr/src/packages/RPMS that can be installed as any other RPM package. Remember that checkinstall is not the way to prepare a program to install it beyond your own computer.
Most packages will normally be working. Sometimes, and this goes double for older and more complex programs, things don't work. As you should have looked for alternatives and pre-compiled RPM packages, you will need to look what is wrong. Read the error messages. If it says that it cannot find something, most likely you did not have it installed. Copy and paste these error messages if you are asking others for help.
It's a good idea to read the programmer's web site. Very often, when the application needs special libraries, the compilation is very well described there (better than in the README or INSTALL files).
In short what you need to do is:
(If anything fails: read the errors)
Navigate to the directory with Konqueror, open the new RPM file, and click install with YaST
Some places where to look for software: