0
Most of the time, especially in the Windows and Mac OS X world, end users don't have to compile software. The programmers of the software write the code and then compile it into a "binary executable" for you.
However, thanks to the popularity of open-source software, where the source code is available for one and all to read and enjoy, the impetus has been put on the end-user to compile their own code if they want to use the software.
If you find yourself having to (or wanting to) compile a piece of software, don't panic. The process is fairly simple. Every piece of software is different, but here is a summary of the most common scenario for Unix-based OS such as Linux or Mac OSX. These instructions are not so useful for Windows, as apps are usually built with special GUI development tools, not command line tools.

Downloading a Compiler

Linux You almost certainly already have a command line, and a compiler called gcc. Try typing gcc on the command line. If it tells you command not found, install gcc using your package manager.
Mac OS X Your command line is Terminal, which is located in Applications/Utilities. You'll need to download XCode, which contains Apple's compiler, from the Apple developer tools web site. XCode is often bundled on the operating system CD or DVD that comes with your computer.
Windows Microsoft provides a compiler with its free downloadable GUI development environmentVisual Studio Express, but Cygwin is both more useful and more Unix-compatible. Download and install it, making sure to include all the packages from the "Devel" section when you choose packages.

Obtaining the Source Code

Downloading Practically all source packages come in a zipped-up archive file. This will have the suffix .tgz or .tar.gz. (on Windows .zip) It will also have a name and a version number, something like example-3.2.8.tar.gz. You should make yourself a directory to work in, called "source" or "build" or something along those lines. Using a browser, download the source file into that directory.For novice linux users, do not type code on the command line.
Unpacking From your command line, go into your working directory (using the cd command):
$ cd /source/code
The quickest way to unzip the archive is tar:
$ tar -xzvf example-3.2.8.tar.gz
(on Windows, right-click on the .zip file and select Extract All...)
This will unzip all the files of the source code into a new subdirectory with the same name as your application, including the version number. Go into this directory by typing:
$ cd /example-3.2.8
Reading the Documentation Practically every source package contains some reading material, typically files with names in all caps, like README and INSTALL. Read these! They tell you how to proceed. There may also be documentation for your specific situation, like README.macosx. You can use the less command on the command line to read them:
$ less INSTALL
or just open them in your favorite text editor. The documentation may point you to other software that you need to install before you can install this package ("dependencies"), or to quirks of the installation process that you need to be alert for. Much of this may be covered on the software's web page as well.
Building The process may differ (especially on Windows), but the most common procedure is as follows. Type:
$ ./configure
The dot-slash beforehand means you want to run the configuration tool in the current directory. This runs some diagnostic tests on your computer, figuring out whether the software has everything it needs and where important files are. You might have to specify the location of certain files on your computer if they're not in the obvious place -- the documentation should cover this; e.g.:
$ ./configure --ssl-dir=/usr/local/include
For a full list of all the options you can give to the configure tool, run:
$ ./configure --help
The configuration process may take several minutes. When it's done, if it doesn't give you an error message, you're ready to compile. If it does give you an error message, refer to the Troubleshooting section below. To compile the software, just type:
$ make
This performs the meat of the operation. If all goes well, it should take a while, and may monopolize your computer's processor while it's running. Don't worry, compiling software is intensive work. When it ends, if you don't see an error message, you're ready for the last step. Note that you probably won't see a congratulations message either.
The software has been compiled. All that remains to do is to put it where it belongs.
$ make install
will place the various files that have been built in their proper locations in the filesystem. Now they're ready to be used. Often, you will need to run make install with root level permissions so the files can be copied to the correct location.
$ sudo make install
Most systems have the sudo command, which will allow you to run commands as the super-user. Note that, when running commands with sudo you will be prompted for a password.You have to set up a sudo account before running sudo.
Troubleshooting If any of the steps above don't go smoothly, there are a few systematic steps to take that will help you figure out what the problem is. Make sure you've followed all the instructions rigorously, and that you have any necessary dependencies installed.
If you can't figure out where you went wrong, search for the error message you received, on Google, Usenet, and in the forums and/or mailing list archives for the software. If that fails, you can probably e-mail the mailing list with your question, or even contact the software's author directly if there's no active mailing list. Either way, be sure you've done your homework first. Here is a good tutorial on how to ask for help.
The Short Version for Mac OS X: Five typed lines
Double-click the download file in the gui to to extract all popular archiving formats like zip, bz2, gz, etc and save the first line. In Terminal (Applications > Utilities > Terminal), submit the following lines:
  1. bzip2 -cd FILENAME.tar.bz2
  2. cd nmap-5.00
  3. ./configure
  4. make
  5. sudo make install

In the Future
Compiling source code is still a complicated matter compared to other installation tools. It's a problem operating systems have been dealing with for years. However, tools like APT (Debian/Ubuntu Linux),RPM (Fedora/Red-Hat Linux), and Macports (Mac OS X) are making it easy to just point your computer to a URL to download, install, and update your software.
Source : Wired
Photo Artonice via Flickr / CC BY-SA 2.0

Post a Comment

 
Top