How to build from source code in GNU/Linux

Mike Turcotte-McCusker
May 24, 2017
Updated • May 23, 2017

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

  • make

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:

  1. Download the source file and extract it.
  2. Run ./configure
  3. Run make
  4. Run sudo make install

Final Words

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!

How to build from source code in GNU/Linux
Article Name
How to build from source code in GNU/Linux
Mike explains how to build a software program from source on GNU/Linux devices. He uses Pidgin as an example, and walks you through all steps.
Ghacks Technology News

Previous Post: «
Next Post: «


  1. 420 said on May 27, 2017 at 4:08 am

    I got to admit the arch linux forums are pretty brutal to newbs. Trial by fire. Luckily they make Manjaro, a few tradeoffs and I never have to talk to them. On topic, I appreciate someone is bothering to write stuff about linux and Martin is providing a format. I myself would probably not try to take on such a vast topic as how to build stuff from source in linux, but it does get the ball rolling, thank you.

  2. Owl said on May 25, 2017 at 6:45 am

    Clairvaux: Really? Allthough you do admit ‘because I haven’t been there myself’… Most people would get by fine when switching from Windows using the repositories, and there is plenty of information for those who want to get into compiling, unless you are using vague search terms and reading ancient articles by those who want to grandstand?

    Thanks for the article Mike.

    1. ams said on May 25, 2017 at 6:21 pm

      Whatis “ancient articles by those who want to grandstand”?

      an example of “undisclosed quirks” and the “need to continually, eternally, forced to revisit docs”:

      During build, it pukes and spews an “error in makefile” message. What?!? All i did was add one simple line. Search, search, search… an hour later discover that a leading Tab character is expected (4 spaces instead a Tab character is what made the build fail. Seriously?!? Yeah.) Oh, but end-of-line TRAILING spaces ARE permitted… ‘cept on tuesdays?

      Don’t have the energy right now to wade through the heap of dead kittens between here and the door.

    2. Clairvaux said on May 25, 2017 at 5:22 pm

      @ Owl

      Thank you for illustrating my point so perfectly. I just wrote :

      “In place of that, what we usually get is : you’re a cunt for not using Linux ! use Linux, you dickhead ! you’re killing kittens if you’re not using Linux ! What ? you don’t even know what building from source is ? educate yourself, you dummy ! and so on.”

      And here you come out of the woodwork, trying the best you can to convince everybody that Linux aficionados are obnoxious, arrogant individuals always attempting to pick up a fight about nothing.

      It’s sad enough that people get sectarian and aggressive about subjects such as politics, race or religion, but trolling a thread where the most life-engaging issue is the choice between two different technologies for a personal computer… Have you considered taking up boxing, to channel your aggressivity ? At least, you would get a chance to take up a beating in return for dishing it out.

  3. ams said on May 24, 2017 at 8:39 pm

    After reading the first comment, I wanted to reply to it. Same when I read the second comment here.
    Instead, I’m adding this as a freestanding comment.

    It’s tough to balance “let’s educate and generate enthusiasm among potential DIYers” vs “mentioning ‘negative effects’, caveats, gotchas, etc”. At the very VERY least, an introductory article like this should cite multiple “For further reading” links.

    idunno Arch. Are the instructions provided in the article technically correct? tar -xf ??? (I would expect to explicitly pass a commandline arg which instructs “preserve permissions when untarring.) Even _if_ the default behavior of tar, in an Arch system is to preserve permissions, as a BestPractice, I would still instruct explicit declaration of that arg… besides, it’s reasonable to expect that 99+ percent of the ghacks readers are NOTnotNOT using ArchLinux (nor will be, any time soon).

    Clairvaux, I continually find that “supposed to already know about all that” doesn’t hold true ~~ I’m constantly, eternally, forced to scour docs, manpages, stackexchange/stackoverflow, due to changes across versions of (program, build system, dependent libraries) as well as differences between various linux distributions. One size does _NOT_ fit all; tweakamundo is usually required. Quick, simple example: build n install a given gnome app… only to discover that it doesn’t show up in your (xfce, openbox, etc) desktop menu. Why? Because the selfish?dumbass? developer included instructions within .desktop launcher file: “ShowOnlyIn=Gnome”

    I’m a serious linux afficionado, yet at the same time, have learned to embrace the motto:
    LINUX IS FREE (if your time is worthless)

    If this article had been framed as (titled as):
    TIL (aka “today I learned”) Howto compile Pidgin in ArchLinux
    I would say “kudos”… but framed as a general HOWTO BUILD STUFFS IN LINUX, it’s woefully inadequate (and quite likely misleading, in terms of requisite details)

    1. Clairvaux said on May 24, 2017 at 9:02 pm

      – LINUX IS FREE (if your time is worthless) –

      Very nice, and very probably true (that slight disclaimer because I haven’t been there myself — yet).

      N.B.: Arch seems to be one of the difficult distros…

  4. Clairvaux said on May 24, 2017 at 7:06 pm

    Ha ! I’ve been waiting for this article for years. Not saying I will actually convert to Linux and start building from code, but I’ve never seen anyone addressing the problem and trying to explain people what it’s about.

    Maybe this exists on Linux sites, but when you’re a Linuxist you’re supposed to already know about all that anyway.

    Even the first paragraph is news to me — never mind the details about how to do it.

    Anything that makes Linux something else than a watering-hole for sectarian fanatics has to be welcome.

    1. foolishgrunt said on May 24, 2017 at 8:16 pm

      I started using Ubuntu in 2007 as a student with no previous exposure to Linux – I just liked that it was free and decided to give it a try. I don’t remember where I saw it (probably on the Ubuntu forums), but I came across a tutorial for compiling from source in my first few days. I migrated to Arch once I had learned the Linux ropes and was ready for a more technically-elegant distro. :)

      All that to say, I think you’re overstating how difficult it is to find Linux answers.

      1. Clairvaux said on May 24, 2017 at 8:55 pm

        Let me clarify. It’s not as much about the difficulty of finding Linux answers if you’re really trying (that implies you’ve already made the jump). I don’t know about that, because I’m not using Linux (apart from briefly dipping a toe).

        It’s about explaining Linux basics to non-Linux users. Such as : not only there’s less software available, but you’ve got to compile it yourself. OK, but many Linux programs are now pre-compiled, so that makes it easier (although it’s still, on the whole, more difficult). And by the way, if you need, or want, to compile them yourself, here is what it roughly looks like (spare me the details, please). What’s a tarball ? Can you speak english ? etc.

        In place of that, what we usually get is : you’re a cunt for not using Linux ! use Linux, you dickhead ! you’re killing kittens if you’re not using Linux ! What ? you don’t even know what building from source is ? educate yourself, you dummy ! and so on.

  5. Anonymous said on May 24, 2017 at 4:06 pm

    >unless you use Gentoo
    Or funtoo, crux, calculate, exherbo and list goes on.
    Article doesn’t mention negative effects from building from source instead of using your distro package manager solution (and no word about checkinstall for all debian-based system out there, sigh). Also, one of most important part is actually start ./configure –help and look at options before building anything, most important part being install your build-from-source software anywhere, where is doesn’t collision with your package manager (i.e. /usr/local; /opt), so at least ./configure –prefix=/usr/local need to be pointed out.

    More details is always usefull I think.

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.