Table of Contents

PLEASE NOTE THAT THIS PAGE IS A WORK IN PROGRESS

Building Software from Source Code

Abstract

How to use commonly accepted methods for building software from source code. This software may be from a developer's tar.gz (tarball) download, from github.com or other git repositories such as SourceForge or Gitlab. Other source code repository types also exist but are largely no longer used in favor of git.

The process is largely the same for an organized system of building. This discussion will focus on Linux as the operating system since developers of Windows programs commonly provide installer packages for the pre-compiled binaries.

NOTE: the character "~" (tilde) is used in the Linux shell to denote the currrent user's home folder. This shortcut makes writing shell scripts much more compact, and does not require the writer to know that current user's home folder location at all.

Kickin' it old school. The TARBALL (is that the proper British spelling?)

Background

Before git was a thing, developers who shared code commonly used the “tar” utility to create a package of the source code necesary to build a project. It was also commonly compressed to save transmission time over the internet when downloaded. So the typical “tarball” package is named by the project name or executable name with the extension “tar.gz”.

Unrolling the tarball

Download the tarball to the folder in which you wish to place the repository. Commonly, we create a folder named “src” or “source” in our home folder for this use.

Now that the tarball is in the “src” folder, use the tar command to extract the source code files and other resources.

tar xvzf MyProgram.tar.gz

This will create the folder structure contained inside the tarball under the “src” folder, so what is created will look like

./src/MyProgram/<source code files>

Now the source “tree” is ready to be configured and built.

Giddyap with git

Background

Now that git IS a thing, most projects are offered to end users via Github, Gitlab and other online git repositories.

Each project commonly has a home page accessible via web browser. This page gives information about the project including it's license class and other requirements for building the project. The README.md file is typically displayed on this web page so the prospective user may decide if the project is interesting. Usually, this web page also displays a link to use in order to clone the repository.

Cloning from a git repository

Copy the link provided by the web page or other source and use it to clone the repository. The example below is for using a github.com repository

cd ~/src

git clone https://github.com/guitarpicva/RPiKeyerTerm.git

The source code now resides in the folder ~/src/RPiKeyerTerm for this project.

Building from the Source Tree

Background

There are many ways to prepare the source code for building, including doing nothing at all. Commonly, the developer will include building instructions in the README file or another text file which is frequently called INSTALL. Pay attention to full capitalized filenames because it is very common to use this convention in order to draw attention to textual information files in the root folder of a source code tree.

Commonly Used Steps for Building Source Code

Now that the source code tree is in the user's home folder area, follow the advice of the developer usually containted in the INSTALL or README text files included with the source code. Ways to prepare and build are usually detailed in one or more of these text files.

Commonly Used Steps with the Tarball Repository Linux make tools are frequently used in tarball repositories. This means the use of the ./configure script which is usually included with the source code. This is followed by the “make” step and usually by a “sudo make install” step to add the newly created program to the Linux system.

From the top level of the source code tree:

./configure

make

sudo make install

Evaluate the results of each step as you go to ensure that no errors are called out. If errors exist, go back to the README or INSTALL files and ensure that you have taken all pre-requisite steps required by the developer.

PLEASE NOTE THAT THIS PAGE IS A WORK IN PROGRESS