How to build from source code in GNU/Linux
Most repositories for many GNU/Linux distributions have mass amounts of software and packages available within them; itâ€™s becoming more and more rare you are required to build anything from source (unless you use Gentoo), however, many users are left unaware of how to do so if the need ever arises.
This tutorial will show you from beginning to end, how itâ€™s done. I use Arch Linux, so little quirks may arise that are slightly different from distributions like Ubuntu, but the process is nearly identical, except when fulfilling dependencies comes into play.
Note: This tutorial will be done almost entirely within the command line, so be prepared to get your hands a little dirty and have a terminal window open!
We are going to build Pidgin, from source. Pidgin is a popular multi-protocol chat client, used to connect to multiple different chats at once, such as Skype and Facebook Messenger (There is an article here on Ghacks, showing how to connect to those very two)
Pidgin is available in most distribution repositories, but I thought we would build it, since itâ€™s simple, easily done, and wonâ€™t get super complicated for your first time building.
Step 1: Download the source
First thing we need to do, is get our sourcefiles! You can grab them from here.
Once those are downloaded, pop open your terminal and navigate to your Downloads folder (or wherever you downloaded that tarball to)
- cd /Downloads
Next, we need to unpackage the archive, we do this via the â€˜tarâ€™ command
- tar -xf pidgin-2.12.0.tar.bz2
the -x tells tar to extract the file
the f tells tar to read the archive content from a file, like our pidgin-2.12.0.tar.bz2
next, we cd into the directory
- cd pidgin-2.12.0/
Next, we need to configure the source code for our machine, and ensure that we have all the necessary dependencies required to build the source.
Typically this is done simply by typing ./configure, however, I know that pidgin is going to error if you do that because most distributions do not have the necessary packages to compile two parts of Pidgin: required for TCL support (an older programming language rarely used anymore), as well as packages needed to support â€˜meanwhileâ€™, which is needed for using Pidgin with â€œSametime,â€ an IBM instant messaging service/product.
So, unless you specifically need support for TCL or Sametime, we are going to tell our system to disable building those packages into Pidgin, therefore bypassing our need to fulfill those requirements to configure the application!
- ./configure --disable-meanwhile â€“disable-tcl
if everything goes well (as it did on my very minimal Arch Linux install, so users of more robust distributions also â€˜shouldnâ€™tâ€™ run into issues), youâ€™ll get a bunch of scrolling text on the screen, eventually telling you:
configure complete, now type 'make'
...Which is exactly what we do next
Youâ€™re going to see a whole bunch of text absolutely flood your terminal at this point. You on the other hand are going to go get a coffee, walk the dog, or post that image on social media youâ€™ve been wanting to post and kept putting off; this is going to take a few minutes (it took around 5 minutes or so on my laptop)
Once thatâ€™s finally finished, the last step is to install Pidgin!
- sudo make install
When the wall of text is finished, so are you!
Note: I had to log out and back in, before Pidgin showed up in my applications menu. If you donâ€™t see it, try that.
To sum it up:
- Download the source file and extract it.
- Run ./configure
- Run make
- Run sudo make install
Thatâ€™s it! That is the basics of compiling applications from source. Some applications are done a little differently, but that is another topic for another day; youâ€™ll find this process is the same for many, many programs. So, enjoy!Advertisement