How to install programs from source code
By mwananchi
In PCLinuxOS, it is strongly advised to install programs only from the official repositories through Synaptic, and users are advised to look there first for programs they want. If a program isn't there, it can be requested on the main PCLinuxOS forum in the request section. Sometimes, installing programs from source may be a more desirable option than the previous two, and this is a tutorial on how to do that. Installing a program from source is a 3 stage process.
Running a configuration script:
In this stage, a program checks to see if the system meets all of the program's requirements and some other, system-specific variables. A custom install can be built by passing various options to the script at this stage. If a system fails to meet the requirement, the script will stop with an error message specifying what requirement wasn't met. Synaptic should be the first place to go look for the missing program, library, etc. Often, what is needed is the development package of the program; development package names usually end with "dev."
If a --prefix option is not passed to the script, most scripts will use /usr/local, but others will use /usr. For the sake of consistency, it is generally advised to pass this option. It is a convention in Linux to install personal programs in /usr/local, and to have the ones being managed by the distro, in /usr. This ensures personal programs/versions can coexist with the ones being managed by the distro (through Synaptic).
Some programs will have a list of programs that must be installed for the configure stage to pass successfully. It might be a good idea to check the requirements before running the configure script. This will allow you to avoid the annoyances of having to meet each requirement, one at a time (often referred to as dependency hell). Some programs will have a readme file with the source code; it is a good idea to read this file first, before doing anything, as it may contain specific instructions. The help option (./configure --help) might provide other useful options, if a custom installation is desirable.
Make:
In this step, the source code of the program (usually in text format) is translated to machine code (binary format ). This stage is usually the longest (it could take a couple of minutes, or many hours for large applications). The make program will bail out at the first sign of trouble and, if you don't want to go through the source code to correct the trouble yourself, I would suggest you just delete the program and forget about it. Then you could exercise your option to request the package in the request section of the forum.
Make install:
The last stage is the installation of the program (assuming the previous stages passed successfully). At this stage, the binaries made in the previous stage are placed in the appropriate places in your system and necessary changes are made to make them run. Desktop icons, entries to the menu, and file association entries are not made; these must be done manually.
These 3 stages can be done step by step or all at once. From inside the folder containing source code of the program to be installed, press "F4" to launch a terminal, then type: ./configure --prefix=/usr/local (note the dot at the beginning). When that's done, type: make to build the program. Finally, type: su -c make install to install the program. This last stage will prompt you for a root password (assuming you are not root already).
Those 3 stages can be combined into a single line with this command: su -c "./configure --prefix=/usr/local ; make ; make install" if you are not root, or just with: ./configure --prefix=/usr/local ; make ; make install if you are.
Uninstalling the program:
The program can be uninstalled with: make uninstall from inside the program's source code. This command must be issued with root privileges.
Useful commands to know:
which program_name
This command will return the full path of program_name that will be executed when any program just calls "program_name."
whereis program_name
This command will return full paths of all "program_name" installed on a system.
These two are useful if more than one version of the program is installed in a system.
Interesting notes:
If the --prefix=/usr/local option is passed to the configure script, binary files (or executables), a.k.a .exe in Windows, will be placed in /usr/local/bin. Shared libraries (.so), a.k.a .DLL in Windows, will be installed in /usr/local/lib. Documentation files, icons, images, and other necessary files usually go in /usr/local/share. Global program variables will usually go in the /etc folder.