OK, I am going to use the LZMA-Utils package as an example. This is a bunch of utilities which use LZMA compression.
So, make yourself some space to work in (ALL of this is going to be command line):
mkdir ~/build-work
cd ~/build-work
wget http://tukaani.org/lzma/lzma-4.32.7.tar.gz
Now, look at the extension to the filename '.tar.gz'. We know that means we have to run:
tar -xzvf lzma-4.32.7.tar.gzto uncompress the file. Now change to the directory you just created:
cd lzma-4.32.7Now comes the fun part. You may want to set some configuration options in your program. You may want a video encoder to use specific codecs, or to install the program to a certain location, or to use a certain language, or only to install certain parts of itself. You usually achieve all these goals with the 'configure' command. This is actually a script which comes with the program which sets it all up for you. If there is no configure script that usually means that the program is utterly basic (which may be a good thing) with no options.
For the purposes of this little demonstration, we are not going to actually install the software, because that would be stupid as it would probably break your installation of Linux. If we were going to install the software, we would want to make sure that we specified an install path when we ran the configure script. This option will vary from package to package; you should check the INSTALL or README file in the working directory. If there is no such file, it means the author of the source code is a moron. In this case the option is:
--prefix=/usrto make it install to the /usr folder. PLEASE NOTE this does not actually install the software here when you run 'make' - it just configures the scripts with an install location. You still need to run a separate command to actually perform the install in due course.
You normally set other options in the same way - you can get a list of options by using the option:
--help
So lets run the script.
configure
configure: command not foundOh, for fucks sa... oops
./configure
checking if debugging code should be compiled... noAgain, some brilliant communication by way of error messages here. What the script is trying to tell us is that it has run a series of checks to make sure that the computer it is running on is capable of actually compiling the software. It is checking for special software which the 'make' command uses to load the human readable source code and convert it (or compile it) into computer readable code that can be run. It has come to the conclusion that that software does not work, or is missing.
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... no
checking for g++... no
checking for c++... no
checking for gpp... no
checking for aCC... no
checking for CC... no
checking for cxx... no
checking for cc++... no
checking for cl.exe... no
checking for FCC... no
checking for KCC... no
checking for RCC... no
checking for xlC_r... no
checking for xlC... no
checking for C++ compiler default output file name...
configure: error: C++ compiler cannot create executables
See `config.log' for more details.
What would be helpful is if it could tell you how to get the software. That is actually really easy. In ubuntu just run:
sudo apt-get install build-essentialto install a group of packages that handle software compilation. These include the following:
dpkg-dev: This is a list of packages which are essential. Yes, this is getting recursive. It's not really compiler stuff, but compression software, the patch command and the perl computer language. You probably have most of this installed anyway, but by telling the computer to install this package, it makes absolutely sure you have everything on the list.
g++: This is really the meat and potatoes of the compilation software. This package includes the Gnu C Complier - the 'gcc' in the error message above, as well as come ancillary software.
libc6-dev: this is a bunch of support files for the C language.
make: Go on, just guess what this package contains.
After your installation, try the configure command again.
You should see a stream of messages coming up which I am not going to copy here, but for the sake of comparison with the above here is the first few:
checking if debugging code should be compiled... noNote the 'yes' rather than 'no' answers. Everything should be fine, so run:
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for g++... g++
checking for C++ compiler default output file name... a.out
checking whether the C++ compiler works... yes
maketo compile the software. This will take a few seconds or so.Once the make command has stopped, hopefully without a trail of error messages, you can run:
make checkto run some built in tests. It should tell you that:
All 2 tests passedLet's draw a veil over the appalling use of grammar. To actually run your newly compiled software you can run:
./src/lzma/lzma -Vwhich should return the message:
LZMA command line tool 4.32.7If so, congratulations, you have built software from source code. To install the software - DO NOT DO THIS NOW - you would run:
LZMA SDK 4.32
make installYou will get an error about running this unless you are root, so you would run:
sudo make installinstead. This just copies the files that were created in the 'make' step to the appropriate places in the file system. Once that has finished you can delete the working folder, and you are done!
No comments:
Post a Comment