Why compile an rpm from source?

1

What I know: src.rpm usually contain some kind of tar or compressed source code for the app/library/package Sometimes people recommend you compile from source if the package does not work

What I don't know: Why would you recompile from source? What do I need to compile from source? gcc? xlc?

What I would like to know: Hypothetically, if you have a src rpm could you compile that rpm to run on Fedora and then take the same src rpm to AIX and compile it to run on AIX?

HayekSplosives

Posted 2013-02-06T18:16:59.983

Reputation: 533

yes and no. It's not that simple, as aix may not have all the library and package dependencies. It also means you can alter the ./configure stage of the build, or where the files get installed to. – Sirex – 2013-02-06T18:42:15.390

Answers

4

Well, the .src.rpm contains the source code and information about where the various files and executables should be copied to (installed).

So, yes, you should be able to compile the source both on Fedora and AIX. That does not, however, mean that you could also "install the rpm". Installing consists of copying files to various system folders such as /usr, /etc and so on. Different operating systems expect certain files to be at different locations so there is no guarantee that an .rpm for Fedora will be able to install on AIX. In fact, it is extremely unlikely.

As for compiling, you may want to compile from source to have a binary that is optimized for your particular hardware, or to activate certain compile flags such as the location of specific libraries. In general, if you don't know why you should compile from source, then you probably shouldn't.

If you choose to compile, you will need the appropriate compiler. That can be (among others) gcc or xlc for software written in C or C++, javac for Java etc. Which one you should use depends on the software you are installing and your personal preference. Sometimes, software has been written with specific compilers in mind (using certain options at compile time) and they will complain if you try and compile them with another.

Finally, most *nix source tarballs include a Makefile and a configure script. You will need to have the necessary tools to use them. The configure script is usually a simple BLASH script so as long as you have BASH installed you should be fine. Using the Makefile needs the make command. There are also some other basic tools (such as autoconf and automake and others) that you will need. I have not worked on a RH-based distribution for many years no but if memory serves, this command should install everything you need:

yum groupinstall "Development Tools" 

terdon

Posted 2013-02-06T18:16:59.983

Reputation: 45 216

Thank you for the detailed explanation. This cleared up many ambiguities for me regarding this process. I feel like I've only seen the process from the OS/admin side and not the development and this put things in perspective. – HayekSplosives – 2013-02-06T19:42:30.053

@HayekSplosives if this answers your question, please mark it as accepted so the question can be marked as answered. – terdon – 2013-04-05T13:59:12.247