Compiling

From SlackWiki
Jump to navigation Jump to search

Well compiling a program can be a pain, but it's pretty fun. First you need to get the source you're compiling and read the INSTALL and README files on any weird install techniques. We first need to extract the source:

tar zxvf file.tar.gz

You will now see a bunch of files on your screen, that means it's extracting, now half the programs have a configure script, this means you can enable, disable and tell the program where to install to:

./configure --help

This gives you a list of the options you can compile in or disable options. Now this is a normal compile line:

./configure --prefix=/usr

Now this installs the program in /usr so you don't need to edit the $PATH to launch it, Now 2 other options that you might want to add to some programs are:

--sysconfdir=/etc
--localstatedir=/var

These are pretty self explanatory. You may or may not need to edit these. Some source say $PREFIX/etc or something similar for the --sysconfdir and you might not want that, this is an example of when you need the --sysconfdir=/etc. Now when we have the source configured, you want to compile it:

make

This compiles the actual program. It might take some time, it might not, depending on the source.

If make succeeds without errors, the program is now technically compiled. Some simpler programs can be run directly after compiling, without having to be installed, but most programs need to be fully installed before they can properly run.

To install, one can simply proceed as such:

su
make install

However, the above method does not take advantage of Slackware's package management system, which will make upgrading or uninstalling this program in the future much easier. The preferred way to install programs is through packages-- thus, at this point, the program should be packaged instead of simply running "make install" as root. See Building_A_Package and Checkinstall.

This is just a basic way to compile a program and it's pretty easy to do. Now you know how to compile a program. Good luck.