[CentOS] Guidance: compile education

Frank Cox theatre at melvilletheatre.com
Thu Dec 4 22:49:14 UTC 2014


On Thu, 04 Dec 2014 15:16:28 -0700
Stan Cruise wrote:

> Can I be pointed at methods to learn to compile source against a distro. 

I think you need to ask a more specific question, but this is an overview of the process to give you a place to start with further reading.  Google is your friend here.

To compile programs, you need to install a compiler (usually gcc) and whatever development libraries are required.  Those are usually named something-devel, so if you are compiling a program that uses the SDL library, for example, you need to install the SDL-devel rpm as well.

A lot of software comes with configure and make scripts.  If that's the case, you can compile it by moving into the source directory and typing ./configure (with the dot and slash), then make.  Configure sometimes comes with options for where to install the software after compiling it.  If that's the case, type ./configure --prefix --prefix=/path/to/your/directory instead of just typing ./confgure alone.  After running make, run make install to install the software.

This procedure works, but I personally avoid it if possible.  It's usually a better idea to install rpms on a Centos system.  The effort required to create a rpm for any particular program ranges from absolutely trivial to next to impossible.

If you want to create and/or recompile rpms, you should install rpmdevtools, then run rpmdev-setuptree to create a rpm build tree in your home directory.  Otherwise you will have to compile rpms as the root user which is possible but generally not a really good idea.  (rpmdevtools does a lot of other handy stuff, too.)

The easiest way to create a new rpm (assuming that one doesn't already exist) is to edit an existing spec file for something that's as similar to what you are trying to do as possible.

In many cases you can find an existing rpm for the program that you're trying to install as a Fedora rpm.  If that's the case, download and recompile the Fedora .src.rpm and it will in many cases work perfectly.  Sometimes you need to make some small changes in the spec file but a lot of the time you don't even have to do that.

-- 
MELVILLE THEATRE ~ Real D 3D Digital Cinema ~ www.melvilletheatre.com



More information about the CentOS mailing list