Sign In

    Enjoy FOSSwire's content? Have it delivered! Subscribe

    Dusting Off the Archives - compiling software from scratch

    Installing software on Linux, or any Unix system from the source code is something that is difficult to pick up straight away. Nowadays, the chances you'll need to actually do this are lower, but sometime it's good to know how.

    Back in September, I showed you how most source applications can be compiled and installed.

    Installing software. It’s something that you do quite a lot if you’re like most computer users. On Unix-like systems, there are several different ways you be getting that program however - it’s not necessarily a simple case of double-clicking one setup file.

    One of these ways is to download the program’s source code and compile it yourself. This process can be a little tricky to the uninitiated, but has several benefits - including meaning you’ll have the latest copy of the program and you’ll be able to get a copy if you’re using an operating system or distribution where no pre-built packages are available.

    Unfortunately, the ways different bits of software are built means that this process can differ slightly depending on exactly what you’re working on. If you’re having problems, it might be you’re dealing with something that’s a little different, so you may have to look for more help.

    Something that I didn't mention in that post, but did come up in the comments was how to uninstall software that you've installed in this way. Here's how.

    Provided that you kept that source directory around, in most cases you can simply run the following (as root in most cases):

    # make uninstall

    However, some packages don't implement this particular feature.

    The bottom line is - wherever you can, try and avoid installing from source. But if you have to, this guide should give you a good insight into how.

    Read Post


    Unix fundamentals - compiling software from scratch

    This is a fundamentals post - where we cover a fundamental concept to do with a particular bit of free/open source software so you can learn it, brush up and then be armed with that knowledge for future posts!

    Installing software. It's something that you do quite a lot if you're like most computer users. On Unix-like systems, there are several different ways you be getting that program however - it's not necessarily a simple case of double-clicking one setup file.

    One of these ways is to download the program's source code and compile it yourself. This process can be a little tricky to the uninitiated, but has several benefits - including meaning you'll have the latest copy of the program and you'll be able to get a copy if you're using an operating system or distribution where no pre-built packages are available.

    Unfortunately, the ways different bits of software are built means that this process can differ slightly depending on exactly what you're working on. If you're having problems, it might be you're dealing with something that's a little different, so you may have to look for more help.

    Let's dive in!

    Dependencies

    First of all, there is one usual major pitfall that can be difficult at first when you start compiling software on your own. That is dependencies. In order to build a program, you need to have all the software that program depends on installed. On top of that, you need all of those programs' development files. Confused yet?

    Basically, look around on the program's site for a list of dependencies and then use your OS or distribution package manager to install those dependencies (and the -dev or -devel packages if necessary).

    Download and extract

    If you've got dependencies all ready to go, you need to go and actually download the source code and extract the downloaded file. Most source code is distributed in .tar.gz or .tar.bz2 files, which you can extract from the terminal with (respectively);

    $ tar xzvf filename.tar.gz
    $ tar xjvf filename.tar.bz2

    Pick the relevant line from there (top for .tar.gz, bottom for .tar.bz2).

    Now the files are extracted, you need to change into the new directory and get configuring.

    $ cd nameoffolder

    ./configure

    This step prepares your system to get compiling the code. The configure script checks for dependencies (if you have any unsatisfied ones, you will be told here and configure will fail), makes sure everything is ready to go and generates some files.

    Making sure you're in the directory that extracted, simply do:

    $ ./configure

    Note that most software includes special options you can pass to configure if you wish to customise your build. Check the individual program documentation to see if you need this (or might want it) and follow the specific instructions for the configure step.

    make

    Once configure has finished without any errors (if there were, you may need to backtrack to the dependencies stage), you're ready for the main step. The make command will go through all the source files, compile them into object code and then link it all together to make the executable program.

    $ make

    This could take some time depending on the size and complexity of the application, and it will certainly use some CPU power!

    make install

    Once make has completed, there will be one more step to take. make install copies the finished files out of the temporary source directory and into their final destination on your system (this will probably be somewhere under /usr/local unless you specified otherwise).

    This step will probably need to be executed as root. On most systems, that will be:

    $ su
    [[enter root password when prompted]]
    # make install

    However, on Ubuntu, and other systems that use sudo, it will be:

    $ sudo make install

    This process should take less time than make did, and once it's done your program is installed and ready to run.

    We're all done!

    In the vast majority of cases, this is the simple process you need to undertake to compile from scratch. As I said earlier, however, software differs so always check the official instructions first!


    The quickest way to keying an SSH login

    If you read Peter's tutorial a while back on how to create an SSH key, you probably found it a little annoying that you had to sign in and out of your server multiple times to copy your key over and test it on a remote machine. Stop wasting any more time needlessly typing in your password to upload the key and let ssh-copy-id do it for you.

    You might have seen it in last week's cheat sheet, but I'd like to document it further. Basically, all you need to do is call ssh-copy-id to your server just like you would for ssh:

    ssh-copy-id user@remote.server.net

    When you run that, you will have to type in your password for the remote server, but only once. ssh-copy-id will automatically copy your key over and change the permissions appropriately. No more needless chmod-ing or scp-ing.

    Later on, I'll go into details of a graphical application that will also do this and more for you.


    1. 1
    2. 2
    3. 3
    4. 4